Zelda Classic Coverage Report


Directory: src/
File: src/zc/zc_sys.cpp
Date: 2023-08-19 07:32:41
Exec Total Coverage
Lines: 1658 4250 39.0%
Functions: 129 333 38.7%
Branches: 891 2760 32.3%

Line Branch Exec Source
1 //--------------------------------------------------------
2 // ZQuest Classic
3 // by Jeremy Craner, 1999-2000
4 //
5 // zc_sys.cc
6 //
7 // System functions, input handlers, GUI stuff, etc.
8 // for ZQuest Classic.
9 //
10 //--------------------------------------------------------
11
12 #include "zc/zc_sys.h"
13
14 #include "base/qrs.h"
15 #include "base/dmap.h"
16 #include <stdio.h>
17 #include <stdlib.h>
18 #include <string.h>
19 #include <math.h>
20 #include <map>
21 #include <filesystem>
22 #include <ctype.h>
23 #include <sstream>
24 #include "base/zc_alleg.h"
25 #include "gamedata.h"
26 #include "zc/zc_init.h"
27 #include "init.h"
28 #include "zc/replay.h"
29 #include "zc/cheats.h"
30 #include "zc/render.h"
31 #include "base/zc_math.h"
32 #include "base/zapp.h"
33 #include "dialog/cheatkeys.h"
34 #include "metadata/metadata.h"
35 #include "zc/zelda.h"
36 #include "zc/saves.h"
37 #include "tiles.h"
38 #include "base/colors.h"
39 #include "pal.h"
40 #include "base/zsys.h"
41 #include "qst.h"
42 #include "zc/zc_sys.h"
43 #include "play_midi.h"
44 #include "jwin_a5.h"
45 #include "base/jwinfsel.h"
46 #include "base/gui.h"
47 #include "midi.h"
48 #include "subscr.h"
49 #include "zc/maps.h"
50 #include "sprite.h"
51 #include "zc/guys.h"
52 #include "zc/hero.h"
53 #include "zc/title.h"
54 #include "particles.h"
55 #include "zcmusic.h"
56 #include "zconsole.h"
57 #include "zc/ffscript.h"
58 #include "dialog/info.h"
59 #include "dialog/alert.h"
60 #include "zc/combos.h"
61 #include "zc/jit.h"
62 #include <fmt/format.h>
63 #include "zinfo.h"
64 #include "base/misctypes.h"
65
66 #ifdef __EMSCRIPTEN__
67 #include "base/emscripten_utils.h"
68 #endif
69
70 extern FFScript FFCore;
71 extern bool Playing;
72 int32_t sfx_voice[WAV_COUNT];
73 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c);
74 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c);
75
76 extern byte monochrome_console;
77
78 extern HeroClass Hero;
79 extern FFScript FFCore;
80 extern ZModule zcm;
81 extern zcmodule moduledata;
82 extern sprite_list guys, items, Ewpns, Lwpns, Sitems, chainlinks, decorations;
83 extern particle_list particles;
84 extern int32_t loadlast;
85 extern char *sfx_string[WAV_COUNT];
86 byte use_dwm_flush;
87 byte use_save_indicator;
88 int32_t paused_midi_pos = 0;
89 byte midi_suspended = 0;
90 byte zc_192b163_warp_compatibility;
91 char modulepath[2048];
92 bool epilepsyFlashReduction;
93 signed char pause_in_background_menu_init = 0;
94 byte pause_in_background = 0;
95 bool is_sys_pal = false;
96 static bool load_control_called_this_frame;
97 extern PALETTE* hw_palette;
98 extern bool update_hw_pal;
99 extern const char* dmaplist(int32_t index, int32_t* list_size);
100 int32_t getnumber(const char *prompt,int32_t initialval);
101
102 extern bool kb_typing_mode; //script only, for disbaling key presses affecting Hero, etc.
103 extern int32_t cheat_modifier_keys[4]; //two options each, default either control and either shift
104 //extern byte refresh_select_screen;
105 //extern movingblock mblock2; //mblock[4]?
106 //extern int32_t db;
107
108 static const char *ZC_str = "ZQuest Classic";
109 #if defined(ALLEGRO_WINDOWS)
110 const char *qst_dir_name = "win_qst_dir";
111 static const char *qst_module_name = "current_module";
112 #elif defined(ALLEGRO_LINUX)
113 const char *qst_dir_name = "linux_qst_dir";
114 static const char *qst_module_name = "current_module";
115 #elif defined(__APPLE__)
116 const char *qst_dir_name = "osx_qst_dir";
117 static const char *qst_module_name = "current_module";
118 #endif
119 #ifdef ALLEGRO_LINUX
120 static const char *samplepath = "samplesoundset/patches.dat";
121 #endif
122 char qst_files_path[2048];
123
124 #ifdef _MSC_VER
125 #define getcwd _getcwd
126 #endif
127
128 bool rF11();
129 bool rI();
130 bool rQ();
131 bool zc_key_pressed();
132
133 #ifdef _WIN32
134
135 // This should only be necessary for MinGW, since it doesn't have a dwmapi.h. Add another #ifdef if you like.
136 extern "C"
137 {
138 typedef HRESULT(WINAPI *t_DwmFlush)();
139 typedef HRESULT(WINAPI *t_DwmIsCompositionEnabled)(BOOL *pfEnabled);
140 }
141
142 void do_DwmFlush()
143 {
144 static HMODULE shell = LoadLibrary("dwmapi.dll");
145
146 if(!shell)
147 return;
148
149 static t_DwmFlush flush=reinterpret_cast<t_DwmFlush>(GetProcAddress(shell, "DwmFlush"));
150 static t_DwmIsCompositionEnabled isEnabled=reinterpret_cast<t_DwmIsCompositionEnabled>(GetProcAddress(shell, "DwmIsCompositionEnabled"));
151
152 BOOL enabled;
153 isEnabled(&enabled);
154
155 if(isEnabled)
156 flush();
157 }
158
159 #endif // _WIN32
160
161 83751 bool flash_reduction_enabled(bool check_qr)
162 {
163
4/4
✓ Branch 0 taken 81530 times.
✓ Branch 1 taken 2221 times.
✓ Branch 2 taken 81074 times.
✓ Branch 3 taken 83295 times.
83751 return (check_qr && get_qr(qr_EPILEPSY)) || epilepsyFlashReduction || replay_is_debug();
164 }
165
166 // Dialogue largening
167 void large_dialog(DIALOG *d)
168 {
169 large_dialog(d, 1.5);
170 }
171
172 void large_dialog(DIALOG *d, float RESIZE_AMT)
173 {
174 if(!d[0].d1)
175 {
176 d[0].d1 = 1;
177 int32_t oldwidth = d[0].w;
178 int32_t oldheight = d[0].h;
179 int32_t oldx = d[0].x;
180 int32_t oldy = d[0].y;
181 d[0].x -= int32_t(d[0].w/RESIZE_AMT);
182 d[0].y -= int32_t(d[0].h/RESIZE_AMT);
183 d[0].w = int32_t(d[0].w*RESIZE_AMT);
184 d[0].h = int32_t(d[0].h*RESIZE_AMT);
185
186 for(int32_t i=1; d[i].proc !=NULL; i++)
187 {
188 // Place elements horizontally
189 double xpc = ((double)(d[i].x - oldx) / (double)oldwidth);
190 d[i].x = int32_t(d[0].x + (xpc*d[0].w));
191
192 if(d[i].proc != d_stringloader)
193 {
194 if(d[i].proc==d_bitmap_proc)
195 {
196 d[i].w *= 2;
197 }
198 else d[i].w = int32_t(d[i].w*RESIZE_AMT);
199 }
200
201 // Place elements vertically
202 double ypc = ((double)(d[i].y - oldy) / (double)oldheight);
203 d[i].y = int32_t(d[0].y + (ypc*d[0].h));
204
205 // Vertically resize elements
206 if(d[i].proc == jwin_edit_proc || d[i].proc == jwin_check_proc || d[i].proc == jwin_checkfont_proc)
207 {
208 d[i].h = int32_t((double)d[i].h*1.5);
209 }
210 else if(d[i].proc == jwin_droplist_proc)
211 {
212 d[i].y += int32_t((double)d[i].h*0.25);
213 d[i].h = int32_t((double)d[i].h*1.25);
214 }
215 else if(d[i].proc==d_bitmap_proc)
216 {
217 d[i].h *= 2;
218 }
219 else d[i].h = int32_t(d[i].h*RESIZE_AMT);
220
221 // Fix frames
222 if(d[i].proc == jwin_frame_proc)
223 {
224 d[i].x++;
225 d[i].y++;
226 d[i].w-=4;
227 d[i].h-=4;
228 }
229 }
230 }
231
232 for(int32_t i=1; d[i].proc!=NULL; i++)
233 {
234 if(d[i].proc==jwin_slider_proc)
235 continue;
236
237 // Bigger font
238 bool bigfontproc = (d[i].proc != d_midilist_proc && d[i].proc != jwin_droplist_proc && d[i].proc != jwin_abclist_proc && d[i].proc != jwin_list_proc);
239
240 if(!d[i].dp2 && bigfontproc)
241 {
242 d[i].dp2 = get_zc_font(font_lfont_l);
243 }
244 else if(!bigfontproc)
245 {
246 ((ListData *)d[i].dp)->font = &a4fonts[font_lfont_l];
247 }
248
249 // Make checkboxes work
250 if(d[i].proc == jwin_check_proc)
251 d[i].proc = jwin_checkfont_proc;
252 else if(d[i].proc == jwin_radio_proc)
253 d[i].proc = jwin_radiofont_proc;
254 }
255
256 jwin_center_dialog(d);
257 }
258
259
260 /**********************************/
261 /******** System functions ********/
262 /**********************************/
263
264 static char cfg_sect[] = "zeldadx"; //We need to rename this.
265 static char ctrl_sect[] = "Controls";
266 static char sfx_sect[] = "Volume";
267
268 int32_t d_dummy_proc(int32_t,DIALOG *,int32_t)
269 {
270 return D_O_K;
271 }
272
273 bool is_reserved_key(int c)
274 {
275 switch(c)
276 {
277 case KEY_ESC:
278 return true;
279 }
280 return false;
281 }
282 bool is_reserved_keycombo(int c, int modflag)
283 {
284 if(c==KEY_F4 && (modflag&KB_ALT_FLAG))
285 return true;
286 return false;
287 }
288 bool checkcheat(Cheat cheat)
289 {
290 if(cheatkeys[cheat][0] && zc_readkey(cheatkeys[cheat][0]))
291 return true; //Main key pressed
292 if(cheatkeys[cheat][1] && zc_readkey(cheatkeys[cheat][1]))
293 return true; //Alt key pressed
294 return false;
295 }
296 116 void load_default_cheatkeys()
297 {
298 116 memset(cheatkeys, 0, sizeof(cheatkeys));
299 116 cheatkeys[Cheat::Life][0] = KEY_H;
300 116 cheatkeys[Cheat::Life][1] = KEY_ASTERISK;
301 116 cheatkeys[Cheat::Magic][0] = KEY_M;
302 116 cheatkeys[Cheat::Magic][1] = KEY_SLASH_PAD;
303 116 cheatkeys[Cheat::Rupies][0] = KEY_R;
304 116 cheatkeys[Cheat::Bombs][0] = KEY_B;
305 116 cheatkeys[Cheat::Arrows][0] = KEY_A;
306 116 cheatkeys[Cheat::Clock][0] = KEY_I;
307 116 cheatkeys[Cheat::Walls][0] = KEY_F11;
308 116 cheatkeys[Cheat::Fast][0] = KEY_Q;
309 116 cheatkeys[Cheat::Light][0] = KEY_L;
310 116 cheatkeys[Cheat::IgnoreSideView][0] = KEY_V;
311 116 cheatkeys[Cheat::Kill][0] = KEY_K;
312 116 cheatkeys[Cheat::GoTo][0] = KEY_G;
313 116 cheatkeys[Cheat::TrigSecrets][0] = KEY_S;
314 116 cheatkeys[Cheat::ShowL0][0] = KEY_0;
315 116 cheatkeys[Cheat::ShowL1][0] = KEY_1;
316 116 cheatkeys[Cheat::ShowL2][0] = KEY_2;
317 116 cheatkeys[Cheat::ShowL3][0] = KEY_3;
318 116 cheatkeys[Cheat::ShowL4][0] = KEY_4;
319 116 cheatkeys[Cheat::ShowL5][0] = KEY_5;
320 116 cheatkeys[Cheat::ShowL6][0] = KEY_6;
321 116 cheatkeys[Cheat::ShowFFC][0] = KEY_7;
322 116 cheatkeys[Cheat::ShowSprites][0] = KEY_8;
323 116 cheatkeys[Cheat::ShowWalkability][0] = KEY_W;
324 116 cheatkeys[Cheat::ShowEffects][0] = KEY_E;
325 116 cheatkeys[Cheat::ShowOverhead][0] = KEY_O;
326 116 cheatkeys[Cheat::ShowPushblock][0] = KEY_P;
327 116 cheatkeys[Cheat::ShowHitbox][0] = KEY_C;
328 116 cheatkeys[Cheat::ShowFFCScripts][0] = KEY_F;
329 116 }
330 116 void load_game_configs()
331 {
332 116 strcpy(moduledata.module_name,zc_get_config("ZCMODULE",qst_module_name,"classic.zmod"));
333 116 joystick_index = zc_get_config(ctrl_sect,"joystick_index",0);
334 116 js_stick_1_x_stick = zc_get_config(ctrl_sect,"js_stick_1_x_stick",0);
335 116 js_stick_1_x_axis = zc_get_config(ctrl_sect,"js_stick_1_x_axis",0);
336 116 js_stick_1_x_offset = zc_get_config(ctrl_sect,"js_stick_1_x_offset",0) ? 128 : 0;
337 116 js_stick_1_y_stick = zc_get_config(ctrl_sect,"js_stick_1_y_stick",0);
338 116 js_stick_1_y_axis = zc_get_config(ctrl_sect,"js_stick_1_y_axis",1);
339 116 js_stick_1_y_offset = zc_get_config(ctrl_sect,"js_stick_1_y_offset",0) ? 128 : 0;
340 116 js_stick_2_x_stick = zc_get_config(ctrl_sect,"js_stick_2_x_stick",1);
341 116 js_stick_2_x_axis = zc_get_config(ctrl_sect,"js_stick_2_x_axis",0);
342 116 js_stick_2_x_offset = zc_get_config(ctrl_sect,"js_stick_2_x_offset",0) ? 128 : 0;
343 116 js_stick_2_y_stick = zc_get_config(ctrl_sect,"js_stick_2_y_stick",1);
344 116 js_stick_2_y_axis = zc_get_config(ctrl_sect,"js_stick_2_y_axis",1);
345 116 js_stick_2_y_offset = zc_get_config(ctrl_sect,"js_stick_2_y_offset",0) ? 128 : 0;
346 116 analog_movement = (zc_get_config(ctrl_sect,"analog_movement",1));
347
348 //cheat modifier keya
349 116 cheat_modifier_keys[0] = zc_get_config(ctrl_sect,"key_cheatmod_a1",KEY_ZC_LCONTROL);
350 116 cheat_modifier_keys[1] = zc_get_config(ctrl_sect,"key_cheatmod_a2",0);
351 116 cheat_modifier_keys[2] = zc_get_config(ctrl_sect,"key_cheatmod_b1",KEY_ZC_RCONTROL);
352 116 cheat_modifier_keys[3] = zc_get_config(ctrl_sect,"key_cheatmod_b2",0);
353
354 //cheat keys
355 116 load_default_cheatkeys();
356 char buf[256];
357
2/2
✓ Branch 0 taken 4060 times.
✓ Branch 1 taken 116 times.
4176 for(size_t q = 1; q < Cheat::Last; ++q)
358 {
359
1/2
✓ Branch 0 taken 4060 times.
✗ Branch 1 not taken.
4060 if(!bindable_cheat((Cheat)q)) continue;
360 4060 std::string cheatname = cheat_to_string((Cheat)q);
361
1/2
✓ Branch 0 taken 4060 times.
✗ Branch 1 not taken.
4060 util::lowerstr(cheatname);
362 4060 sprintf(buf, "key_cheat_%s_main", cheatname.c_str());
363
1/2
✓ Branch 0 taken 4060 times.
✗ Branch 1 not taken.
4060 cheatkeys[q][0] = zc_get_config(ctrl_sect,buf,cheatkeys[q][0]);
364 4060 sprintf(buf, "key_cheat_%s_alt", cheatname.c_str());
365
1/2
✓ Branch 0 taken 4060 times.
✗ Branch 1 not taken.
4060 cheatkeys[q][1] = zc_get_config(ctrl_sect,buf,cheatkeys[q][1]);
366 4060 }
367
368
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if((uint32_t)joystick_index >= MAX_JOYSTICKS)
369 joystick_index = 0;
370
371 116 Akey = zc_get_config(ctrl_sect,"key_a",KEY_Z);
372 116 Bkey = zc_get_config(ctrl_sect,"key_b",KEY_X);
373 116 Skey = zc_get_config(ctrl_sect,"key_s",KEY_ENTER);
374 116 Lkey = zc_get_config(ctrl_sect,"key_l",KEY_Q);
375 116 Rkey = zc_get_config(ctrl_sect,"key_r",KEY_W);
376 116 Pkey = zc_get_config(ctrl_sect,"key_p",KEY_SPACE);
377 116 Exkey1 = zc_get_config(ctrl_sect,"key_ex1",KEY_A);
378 116 Exkey2 = zc_get_config(ctrl_sect,"key_ex2",KEY_S);
379 116 Exkey3 = zc_get_config(ctrl_sect,"key_ex3",KEY_D);
380 116 Exkey4 = zc_get_config(ctrl_sect,"key_ex4",KEY_C);
381
382 116 DUkey = zc_get_config(ctrl_sect,"key_up", KEY_UP);
383 116 DDkey = zc_get_config(ctrl_sect,"key_down", KEY_DOWN);
384 116 DLkey = zc_get_config(ctrl_sect,"key_left", KEY_LEFT);
385 116 DRkey = zc_get_config(ctrl_sect,"key_right",KEY_RIGHT);
386
387 116 Abtn = zc_get_config(ctrl_sect,"btn_a",2);
388 116 Bbtn = zc_get_config(ctrl_sect,"btn_b",1);
389 116 Sbtn = zc_get_config(ctrl_sect,"btn_s",10);
390 116 Mbtn = zc_get_config(ctrl_sect,"btn_m",9);
391 116 Lbtn = zc_get_config(ctrl_sect,"btn_l",5);
392 116 Rbtn = zc_get_config(ctrl_sect,"btn_r",6);
393 116 Pbtn = zc_get_config(ctrl_sect,"btn_p",12);
394 116 Exbtn1 = zc_get_config(ctrl_sect,"btn_ex1",7);
395 116 Exbtn2 = zc_get_config(ctrl_sect,"btn_ex2",8);
396 116 Exbtn3 = zc_get_config(ctrl_sect,"btn_ex3",4);
397 116 Exbtn4 = zc_get_config(ctrl_sect,"btn_ex4",3);
398
399 116 DUbtn = zc_get_config(ctrl_sect,"btn_up",13);
400 116 DDbtn = zc_get_config(ctrl_sect,"btn_down",14);
401 116 DLbtn = zc_get_config(ctrl_sect,"btn_left",15);
402 116 DRbtn = zc_get_config(ctrl_sect,"btn_right",16);
403
404 116 epilepsyFlashReduction = zc_get_config(cfg_sect,"epilepsy_flash_reduction",0);
405
406 116 digi_volume = zc_get_config(sfx_sect,"digi",248);
407 116 midi_volume = zc_get_config(sfx_sect,"midi",255);
408 116 sfx_volume = zc_get_config(sfx_sect,"sfx",248);
409 116 emusic_volume = zc_get_config(sfx_sect,"emusic",248);
410 116 pan_style = zc_get_config(sfx_sect,"pan",1);
411 // 1 <= zcmusic_bufsz <= 128
412 116 zcmusic_bufsz = vbound(zc_get_config(sfx_sect,"zcmusic_bufsz",64),1,128);
413 116 volkeys = zc_get_config(sfx_sect,"volkeys",0)!=0;
414 116 zc_vsync = zc_get_config(cfg_sect,"vsync",0);
415 116 Throttlefps = zc_get_config(cfg_sect,"throttlefps",1)!=0;
416 116 TransLayers = zc_get_config(cfg_sect,"translayers",1)!=0;
417 116 SnapshotFormat = zc_get_config(cfg_sect,"snapshot_format",3);
418 116 NameEntryMode = zc_get_config(cfg_sect,"name_entry_mode",0);
419 #ifdef __EMSCRIPTEN__
420 if (em_is_mobile()) NameEntryMode = 2;
421 #endif
422 116 ShowFPS = zc_get_config(cfg_sect,"showfps",0)!=0;
423 116 NESquit = zc_get_config(cfg_sect,"fastquit",0)!=0;
424 116 ClickToFreeze = zc_get_config(cfg_sect,"clicktofreeze",1)!=0;
425 116 title_version = zc_get_config(cfg_sect,"title",2);
426 116 abc_patternmatch = zc_get_config(cfg_sect, "lister_pattern_matching", 1);
427 116 pause_in_background = zc_get_config(cfg_sect, "pause_in_background", 0);
428
429 //default - scale x2, 640 x 480
430 116 window_width = resx = zc_get_config(cfg_sect,"window_width",640);
431 116 window_height = resy = zc_get_config(cfg_sect,"window_height",480);
432 116 SaveDragResize = zc_get_config(cfg_sect,"save_drag_resize",0)!=0;
433 116 DragAspect = zc_get_config(cfg_sect,"drag_aspect",0)!=0;
434 116 SaveWinPos = zc_get_config(cfg_sect,"save_window_position",0)!=0;
435 116 scaleForceInteger = zc_get_config("zeldadx","scaling_force_integer",1)!=0;
436 116 stretchGame = zc_get_config("zeldadx","stretch_game_area",0)!=0;
437
438 116 loadlast = zc_get_config(cfg_sect,"load_last",0);
439
440 116 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
441
442 116 zc_color_depth = (byte) zc_get_config(cfg_sect,"color_depth",8);
443
444 116 forceExit = (byte) zc_get_config(cfg_sect,"force_exit",0);
445 116 info_opacity = zc_get_config("zc","debug_info_opacity",255);
446 #ifdef _WIN32
447 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
448 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
449 //use_win7_keyboard_fix = (byte) zc_get_config(cfg_sect,"use_win7_key_fix",0);
450 use_win32_proc = (byte) zc_get_config(cfg_sect,"zc_win_proc_fix",0); //buggy
451
452 // This one's for Aero
453 use_dwm_flush = (byte) zc_get_config("zeldadx","use_dwm_flush",0);
454
455 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
456 #else //UNIX
457 116 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
458 116 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
459 116 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
460 #endif
461 116 clearConsoleOnLoad = zc_get_config("CONSOLE","clear_console_on_load",1)!=0;
462 116 clearConsoleOnReload = zc_get_config("CONSOLE","clear_console_on_reload",0)!=0;
463
464 116 strcpy(qstdir,zc_get_config(cfg_sect,qst_dir_name,""));
465
466
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(strlen(qstdir)==0)
467 {
468 116 getcwd(qstdir,2048);
469 116 fix_filename_case(qstdir);
470 116 fix_filename_slashes(qstdir);
471 116 put_backslash(qstdir);
472 116 }
473 else
474 {
475 chop_path(qstdir);
476 }
477
478 116 strcpy(qstpath,qstdir); //qstpath is the local (for this run of ZC) quest path, qstdir is the universal quest dir.
479 116 ss_enable = zc_get_config(cfg_sect,"ss_enable",1) ? 1 : 0;
480 116 ss_after = vbound(zc_get_config(cfg_sect,"ss_after",14), 0, 14);
481 116 ss_speed = vbound(zc_get_config(cfg_sect,"ss_speed",2), 0, 6);
482 116 ss_density = vbound(zc_get_config(cfg_sect,"ss_density",3), 0, 6);
483 116 heart_beep = zc_get_config(cfg_sect,"heart_beep",1)!=0;
484 //gui_colorset = zc_get_config(cfg_sect,"gui_colorset",0);
485 116 sfxdat = zc_get_config(cfg_sect,"use_sfx_dat",1);
486 116 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
487 116 use_save_indicator = zc_get_config(cfg_sect,"save_indicator",0);
488 116 zc_192b163_warp_compatibility = zc_get_config(cfg_sect,"zc_192b163_warp_compatibility",0);
489 116 }
490
491 void save_control_configs(bool kb)
492 {
493 if(kb)
494 {
495 zc_set_config(ctrl_sect,"key_cheatmod_a1",cheat_modifier_keys[0]);
496 zc_set_config(ctrl_sect,"key_cheatmod_a2",cheat_modifier_keys[1]);
497 zc_set_config(ctrl_sect,"key_cheatmod_b1",cheat_modifier_keys[2]);
498 zc_set_config(ctrl_sect,"key_cheatmod_b2",cheat_modifier_keys[3]);
499
500 if (!replay_is_replaying())
501 {
502 zc_set_config(ctrl_sect,"key_a",Akey);
503 zc_set_config(ctrl_sect,"key_b",Bkey);
504 zc_set_config(ctrl_sect,"key_s",Skey);
505 zc_set_config(ctrl_sect,"key_l",Lkey);
506 zc_set_config(ctrl_sect,"key_r",Rkey);
507 zc_set_config(ctrl_sect,"key_p",Pkey);
508 zc_set_config(ctrl_sect,"key_ex1",Exkey1);
509 zc_set_config(ctrl_sect,"key_ex2",Exkey2);
510 zc_set_config(ctrl_sect,"key_ex3",Exkey3);
511 zc_set_config(ctrl_sect,"key_ex4",Exkey4);
512 zc_set_config(ctrl_sect,"key_up", DUkey);
513 zc_set_config(ctrl_sect,"key_down", DDkey);
514 zc_set_config(ctrl_sect,"key_left", DLkey);
515 zc_set_config(ctrl_sect,"key_right",DRkey);
516 }
517 }
518 else
519 {
520 zc_set_config(ctrl_sect,"joystick_index",joystick_index);
521 zc_set_config(ctrl_sect,"js_stick_1_x_stick",js_stick_1_x_stick);
522 zc_set_config(ctrl_sect,"js_stick_1_x_axis",js_stick_1_x_axis);
523 zc_set_config(ctrl_sect,"js_stick_1_x_offset",js_stick_1_x_offset ? 1 : 0);
524 zc_set_config(ctrl_sect,"js_stick_1_y_stick",js_stick_1_y_stick);
525 zc_set_config(ctrl_sect,"js_stick_1_y_axis",js_stick_1_y_axis);
526 zc_set_config(ctrl_sect,"js_stick_1_y_offset",js_stick_1_y_offset ? 1 : 0);
527 zc_set_config(ctrl_sect,"js_stick_2_x_stick",js_stick_2_x_stick);
528 zc_set_config(ctrl_sect,"js_stick_2_x_axis",js_stick_2_x_axis);
529 zc_set_config(ctrl_sect,"js_stick_2_x_offset",js_stick_2_x_offset ? 1 : 0);
530 zc_set_config(ctrl_sect,"js_stick_2_y_stick",js_stick_2_y_stick);
531 zc_set_config(ctrl_sect,"js_stick_2_y_axis",js_stick_2_y_axis);
532 zc_set_config(ctrl_sect,"js_stick_2_y_offset",js_stick_2_y_offset ? 1 : 0);
533 zc_set_config(ctrl_sect,"analog_movement",analog_movement);
534
535 zc_set_config(ctrl_sect,"btn_a",Abtn);
536 zc_set_config(ctrl_sect,"btn_b",Bbtn);
537 zc_set_config(ctrl_sect,"btn_s",Sbtn);
538 zc_set_config(ctrl_sect,"btn_m",Mbtn);
539 zc_set_config(ctrl_sect,"btn_l",Lbtn);
540 zc_set_config(ctrl_sect,"btn_r",Rbtn);
541 zc_set_config(ctrl_sect,"btn_p",Pbtn);
542 zc_set_config(ctrl_sect,"btn_ex1",Exbtn1);
543 zc_set_config(ctrl_sect,"btn_ex2",Exbtn2);
544 zc_set_config(ctrl_sect,"btn_ex3",Exbtn3);
545 zc_set_config(ctrl_sect,"btn_ex4",Exbtn4);
546
547 zc_set_config(ctrl_sect,"btn_up",DUbtn);
548 zc_set_config(ctrl_sect,"btn_down",DDbtn);
549 zc_set_config(ctrl_sect,"btn_left",DLbtn);
550 zc_set_config(ctrl_sect,"btn_right",DRbtn);
551 }
552 }
553
554 void save_cheatkeys()
555 {
556 char buf[256];
557 for(size_t q = 1; q < Cheat::Last; ++q)
558 {
559 if(!bindable_cheat((Cheat)q)) continue;
560 std::string cheatname = cheat_to_string((Cheat)q);
561 util::lowerstr(cheatname);
562 sprintf(buf, "key_cheat_%s_main", cheatname.c_str());
563 zc_set_config(ctrl_sect,buf,cheatkeys[q][0]);
564 sprintf(buf, "key_cheat_%s_alt", cheatname.c_str());
565 if(cheatkeys[q][1])
566 zc_set_config(ctrl_sect,buf,cheatkeys[q][1]);
567 else zc_set_config(ctrl_sect,buf,(char*)nullptr);
568 }
569 }
570
571 void save_game_configs()
572 {
573 packfile_password("");
574
575 zc_set_config("ZCMODULE",qst_module_name,moduledata.module_name);
576
577 if (all_get_display() && !all_get_fullscreen_flag()&& SaveWinPos)
578 {
579 int o_window_x, o_window_y;
580 al_get_window_position(all_get_display(), &o_window_x, &o_window_y);
581 zc_set_config(cfg_sect,"window_x",o_window_x);
582 zc_set_config(cfg_sect,"window_y",o_window_y);
583 }
584
585 if (all_get_display() && !all_get_fullscreen_flag() && SaveDragResize)
586 {
587 double monitor_scale = zc_get_monitor_scale();
588 window_width = al_get_display_width(all_get_display()) / monitor_scale;
589 window_height = al_get_display_height(all_get_display()) / monitor_scale;
590 zc_set_config(cfg_sect,"window_width",window_width);
591 zc_set_config(cfg_sect,"window_height",window_height);
592 }
593
594 zc_set_config(cfg_sect,"load_last",loadlast);
595 chop_path(qstdir);
596 zc_set_config(cfg_sect,qst_dir_name,qstdir);
597 zc_set_config(cfg_sect,"use_sfx_dat",sfxdat);
598
599 flush_config_file();
600 #ifdef __EMSCRIPTEN__
601 em_sync_fs();
602 #endif
603 }
604
605 //----------------------------------------------------------------
606
607 // Timers
608
609 29937 void fps_callback()
610 {
611 29937 lastfps=framecnt;
612 29937 dword tempsecs = fps_secs;
613 29937 ++tempsecs;
614 //avgfps=((long double)avgfps*fps_secs+lastfps)/(++fps_secs); // DJGPP doesn't like this
615 29937 avgfps=((long double)avgfps*fps_secs+lastfps)/(tempsecs);
616 29937 ++fps_secs;
617 29937 framecnt=0;
618 29937 }
619
620 END_OF_FUNCTION(fps_callback)
621
622 116 int32_t Z_init_timers()
623 {
624 static bool didit = false;
625 const static char *err_str = "Couldn't allocate timer";
626 116 err_str = err_str; //Unused variable warning
627
628
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(didit)
629 return 1;
630
631 116 didit = true;
632
633 LOCK_VARIABLE(lastfps);
634 LOCK_VARIABLE(framecnt);
635 LOCK_FUNCTION(fps_callback);
636
637
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(install_int_ex(fps_callback,SECS_TO_TIMER(1)))
638 return 0;
639
640 116 return 1;
641 116 }
642
643 void Z_remove_timers()
644 {
645 remove_int(fps_callback);
646 }
647
648 //----------------------------------------------------------------
649
650 void go()
651 {
652 blit(screen,tmp_scr,scrx,scry,0,0,screen->w,screen->h);
653 }
654
655 void comeback()
656 {
657 blit(tmp_scr,screen,0,0,scrx,scry,screen->w,screen->h);
658 }
659
660 void dump_pal(BITMAP *dest)
661 {
662 for(int32_t i=0; i<256; i++)
663 rectfill(dest,(i&63)<<2,(i&0xFC0)>>4,((i&63)<<2)+3,((i&0xFC0)>>4)+3,i);
664 }
665
666 //----------------------------------------------------------------
667
668 int game_mouse_index = ZCM_BLANK;
669 static bool system_mouse = false;
670 26 bool sys_mouse()
671 {
672 26 system_mouse = true;
673 26 return MouseSprite::set(ZCM_NORMAL);
674 }
675 555 bool game_mouse()
676 {
677 555 system_mouse = false;
678 555 return MouseSprite::set(game_mouse_index);
679 }
680 void custom_mouse(BITMAP* bmp, int fx, int fy, bool sys_recolor, bool user_scale)
681 {
682 if(!bmp)
683 return;
684 float scale = vbound(zc_get_config("zeldadx","cursor_scale_large",1.5),1.0,5.0);
685 int scaledw = bmp->w*scale, scaledh = bmp->h*scale;
686 if(bmp->w == scaledw && bmp->h == scaledh)
687 user_scale = false;
688 if(user_scale || sys_recolor)
689 {
690 if(!user_scale) scale = 1;
691 BITMAP* tmpbmp = create_bitmap_ex(8,bmp->w*scale,bmp->h*scale);
692 if(user_scale)
693 stretch_blit(bmp, tmpbmp, 0, 0, bmp->w, bmp->h, 0, 0, tmpbmp->w, tmpbmp->h);
694 else
695 blit(bmp, tmpbmp, 0, 0, 0, 0, bmp->w, bmp->h);
696 if(sys_recolor)
697 recolor_mouse(tmpbmp);
698 MouseSprite::assign(ZCM_CUSTOM, tmpbmp, fx*scale, fy*scale);
699 destroy_bitmap(tmpbmp);
700 }
701 else
702 {
703 MouseSprite::assign(ZCM_CUSTOM, bmp, fx, fy);
704 }
705 }
706
707 //Handles converting the mouse sprite from the .dat file
708 void recolor_mouse(BITMAP* bmp)
709 {
710 for(int32_t x = 0; x < bmp->w; ++x)
711 {
712 for(int32_t y = 0; y < bmp->h; ++y)
713 {
714 int32_t color = getpixel(bmp, x, y);
715 switch(color)
716 {
717 case dvc(1):
718 color = jwin_pal[jcCURSORMISC];
719 break;
720 case dvc(2):
721 color = jwin_pal[jcCURSOROUTLINE];
722 break;
723 case dvc(3):
724 color = jwin_pal[jcCURSORLIGHT];
725 break;
726 case dvc(5):
727 color = jwin_pal[jcCURSORDARK];
728 break;
729 default:
730 continue;
731 }
732 putpixel(bmp, x, y, color);
733 }
734 }
735 }
736 void load_mouse()
737 {
738 enter_sys_pal();
739 MouseSprite::set(-1);
740 float scale = vbound(zc_get_config("zeldadx","cursor_scale_large",1.5),1.0,5.0);
741 int32_t sz = 16*scale;
742 for(int32_t j = 0; j < 1; ++j)
743 {
744 BITMAP* tmpbmp = create_bitmap_ex(8,16,16);
745 if(zcmouse[j])
746 destroy_bitmap(zcmouse[j]);
747 zcmouse[j] = create_bitmap_ex(8,sz,sz);
748 clear_bitmap(zcmouse[j]);
749 clear_bitmap(tmpbmp);
750 blit((BITMAP*)datafile[BMP_MOUSE].dat,tmpbmp,1,j*17+1,0,0,16,16);
751 recolor_mouse(tmpbmp);
752 if(sz!=16)
753 stretch_blit(tmpbmp, zcmouse[j], 0, 0, 16, 16, 0, 0, sz, sz);
754 else
755 blit(tmpbmp, zcmouse[j], 0, 0, 0, 0, 16, 16);
756 destroy_bitmap(tmpbmp);
757 }
758 if(!hw_palette) hw_palette = &RAMpal;
759 zc_set_palette(*hw_palette);
760
761 BITMAP* blankmouse = create_bitmap_ex(8,16,16);
762 clear_bitmap(blankmouse);
763
764 MouseSprite::assign(ZCM_NORMAL, zcmouse[0], 1*scale, 1*scale);
765 MouseSprite::assign(ZCM_BLANK, blankmouse);
766 //Don't assign ZCM_CUSTOM. That'll be handled by scripts.
767
768 //Reload the mouse
769 if(system_mouse)
770 sys_mouse();
771 else game_mouse();
772
773 destroy_bitmap(blankmouse);
774 exit_sys_pal();
775 }
776
777 // sets the video mode and initializes the palette and mouse sprite
778 116 bool game_vid_mode(int32_t mode,int32_t wait)
779 {
780
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if (is_headless())
781 116 return true;
782
783 if(set_gfx_mode(mode,resx,resy,0,0)!=0)
784 {
785 return false;
786 }
787
788 scrx = (resx-320)>>1;
789 scry = (resy-240)>>1;
790 for(int32_t q = 0; q < NUM_ZCMOUSE; ++q)
791 zcmouse[q] = NULL;
792 load_mouse();
793
794 for(int32_t i=240; i<256; i++)
795 RAMpal[i]=((RGB*)datafile[PAL_GUI].dat)[i];
796
797 zc_set_palette(RAMpal);
798 clear_to_color(screen,BLACK);
799
800 rest(wait);
801 return true;
802 116 }
803
804 8 void null_quest()
805 {
806 char qstdat_string[2048];
807 8 strcpy(qstdat_string, "modules/classic/default.qst");
808
809 #ifdef __EMSCRIPTEN__
810 // The quest template data file is not included because it's really big and isn't really needed
811 // for the player, except to initialize some graphics. Those same graphics exist in this quest file,
812 // which is much smaller.
813 strcpy(qstdat_string, "modules/classic/title_gfx.dat");
814 #endif
815
816 8 byte skip_flags[4] = { 0 };
817
818 8 loadquest(qstdat_string,&QHeader,&QMisc,tunes+ZC_MIDI_COUNT,false,skip_flags,0,false);
819 8 }
820
821 8 void init_NES_mode()
822 {
823 8 null_quest();
824 8 }
825
826 //----------------------------------------------------------------
827
828 qword trianglelines[16]=
829 {
830 0x0000000000000000ULL,
831 0xFD00000000000000ULL,
832 0xFDFD000000000000ULL,
833 0xFDFDFD0000000000ULL,
834 0xFDFDFDFD00000000ULL,
835 0xFDFDFDFDFD000000ULL,
836 0xFDFDFDFDFDFD0000ULL,
837 0xFDFDFDFDFDFDFD00ULL,
838 0xFDFDFDFDFDFDFDFDULL,
839 0x00FDFDFDFDFDFDFDULL,
840 0x0000FDFDFDFDFDFDULL,
841 0x000000FDFDFDFDFDULL,
842 0x00000000FDFDFDFDULL,
843 0x0000000000FDFDFDULL,
844 0x000000000000FDFDULL,
845 0x00000000000000FDULL,
846 };
847
848 word screen_triangles[28][32];
849 /*
850 qword triangles[4][16]= //[direction][value]
851 {
852 {
853 0x00000000, 0x10000000, 0x21000000, 0x32100000, 0x43210000, 0x54321000, 0x65432100, 0x76543210, 0x87654321, 0x88765432, 0x88876543, 0x88887654, 0x88888765, 0x88888876, 0x88888887, 0x88888888
854 },
855 {
856 0x00000000, 0xF0000000, 0xEF000000, 0xFDF00000, 0xCFDF0000, 0xBCFDF000, 0xABCFDF00, 0x9ABCFDF0, 0x89ABCFDF, 0x889ABCFD, 0x8889ABCD, 0x88889ABC, 0x888889AB, 0x8888889A, 0x88888889, 0x88888888
857 },
858 {
859 0x00000000, 0x00000001, 0x00000012, 0x00000123, 0x00001234, 0x00012345, 0x00123456, 0x01234567, 0x12345678, 0x23456788, 0x34567888, 0x45678888, 0x56788888, 0x67888888, 0x78888888, 0x88888888
860 },
861 {
862 0x00000000, 0x0000000F, 0x000000FE, 0x00000FED, 0x0000FEDC, 0x000FEDCB, 0x00FEDCBA, 0x0FEDCBA9, 0xFEDCBA98, 0xEDCBA988, 0xDCBA9888, 0xCBA98888, 0xBA988888, 0xA9888888, 0x98888888, 0x88888888
863 }
864 };
865 */
866
867
868 /*
869 byte triangles[4][16][8]= //[direction][value][line]
870 {
871 {
872 {
873 0, 0, 0, 0, 0, 0, 0, 0
874 },
875 {
876 1, 0, 0, 0, 0, 0, 0, 0
877 },
878 {
879 2, 1, 0, 0, 0, 0, 0, 0
880 },
881 {
882 3, 2, 1, 0, 0, 0, 0, 0
883 },
884 {
885 4, 3, 2, 1, 0, 0, 0, 0
886 },
887 {
888 5, 4, 3, 2, 1, 0, 0, 0
889 },
890 {
891 6, 5, 4, 3, 2, 1, 0, 0
892 },
893 {
894 7, 6, 5, 4, 3, 2, 1, 0
895 },
896 {
897 8, 7, 6, 5, 4, 3, 2, 1
898 },
899 {
900 8, 8, 7, 6, 5, 4, 3, 2
901 },
902 {
903 8, 8, 8, 7, 6, 5, 4, 3
904 },
905 {
906 8, 8, 8, 8, 7, 6, 5, 4
907 },
908 {
909 8, 8, 8, 8, 8, 7, 6, 5
910 },
911 {
912 8, 8, 8, 8, 8, 8, 7, 6
913 },
914 {
915 8, 8, 8, 8, 8, 8, 8, 7
916 },
917 {
918 8, 8, 8, 8, 8, 8, 8, 8
919 }
920 },
921 {
922 {
923 0, 0, 0, 0, 0, 0, 0, 0
924 },
925 {
926 15, 0, 0, 0, 0, 0, 0, 0
927 },
928 {
929 14, 15, 0, 0, 0, 0, 0, 0
930 },
931 {
932 13, 14, 15, 0, 0, 0, 0, 0
933 },
934 {
935 12, 13, 14, 15, 0, 0, 0, 0
936 },
937 {
938 11, 12, 13, 14, 15, 0, 0, 0
939 },
940 {
941 10, 11, 12, 13, 14, 15, 0, 0
942 },
943 {
944 9, 10, 11, 12, 13, 14, 15, 0
945 },
946 {
947 8, 9, 10, 11, 12, 13, 14, 15
948 },
949 {
950 8, 8, 9, 10, 11, 12, 13, 14
951 },
952 {
953 8, 8, 8, 9, 10, 11, 12, 13
954 },
955 {
956 8, 8, 8, 8, 9, 10, 11, 12
957 },
958 {
959 8, 8, 8, 8, 8, 9, 10, 11
960 },
961 {
962 8, 8, 8, 8, 8, 8, 9, 10
963 },
964 {
965 8, 8, 8, 8, 8, 8, 8, 9
966 },
967 {
968 8, 8, 8, 8, 8, 8, 8, 8
969 }
970 },
971 {
972 {
973 0, 0, 0, 0, 0, 0, 0, 0
974 },
975 {
976 0, 0, 0, 0, 0, 0, 0, 1
977 },
978 {
979 0, 0, 0, 0, 0, 0, 1, 2
980 },
981 {
982 0, 0, 0, 0, 0, 1, 2, 3
983 },
984 {
985 0, 0, 0, 0, 1, 2, 3, 4
986 },
987 {
988 0, 0, 0, 1, 2, 3, 4, 5
989 },
990 {
991 0, 0, 1, 2, 3, 4, 5, 6
992 },
993 {
994 0, 1, 2, 3, 4, 5, 6, 7
995 },
996 {
997 1, 2, 3, 4, 5, 6, 7, 8
998 },
999 {
1000 2, 3, 4, 5, 6, 7, 8, 8
1001 },
1002 {
1003 3, 4, 5, 6, 7, 8, 8, 8
1004 },
1005 {
1006 4, 5, 6, 7, 8, 8, 8, 8
1007 },
1008 {
1009 5, 6, 7, 8, 8, 8, 8, 8
1010 },
1011 {
1012 6, 7, 8, 8, 8, 8, 8, 8
1013 },
1014 {
1015 7, 8, 8, 8, 8, 8, 8, 8
1016 },
1017 {
1018 8, 8, 8, 8, 8, 8, 8, 8
1019 }
1020 },
1021 {
1022 {
1023 0, 0, 0, 0, 0, 0, 0, 0
1024 },
1025 {
1026 0, 0, 0, 0, 0, 0, 0, 15
1027 },
1028 {
1029 0, 0, 0, 0, 0, 0, 15, 14
1030 },
1031 {
1032 0, 0, 0, 0, 0, 15, 14, 13
1033 },
1034 {
1035 0, 0, 0, 0, 15, 14, 13, 12
1036 },
1037 {
1038 0, 0, 0, 15, 14, 13, 12, 11
1039 },
1040 {
1041 0, 0, 15, 14, 13, 12, 11, 10
1042 },
1043 {
1044 0, 15, 14, 13, 12, 11, 10, 9
1045 },
1046 {
1047 15, 14, 13, 12, 11, 10, 9, 8
1048 },
1049 {
1050 14, 13, 12, 11, 10, 9, 8, 8
1051 },
1052 {
1053 13, 12, 11, 10, 9, 8, 8, 8
1054 },
1055 {
1056 12, 11, 10, 9, 8, 8, 8, 8
1057 },
1058 {
1059 11, 10, 9, 8, 8, 8, 8, 8
1060 },
1061 {
1062 10, 9, 8, 8, 8, 8, 8, 8
1063 },
1064 {
1065 9, 8, 8, 8, 8, 8, 8, 8
1066 },
1067 {
1068 8, 8, 8, 8, 8, 8, 8, 8
1069 }
1070 }
1071 };
1072 */
1073
1074
1075
1076 /*
1077 for (int32_t blockrow=0; blockrow<30; ++i)
1078 {
1079 for (int32_t linerow=0; linerow<8; ++i)
1080 {
1081 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1082 for (int32_t blockcolumn=0; blockcolumn<40; ++i)
1083 {
1084 triangleline=triangles[0][screen_triangles[blockrow][blockcolumn]][linerow];
1085 ++triangleline;
1086 }
1087 }
1088 }
1089 */
1090
1091 // the ULL suffixes are to prevent this warning:
1092 // warning: integer constant is too large for "int32_t" type
1093
1094 qword triangles[4][16][8]= //[direction][value][line]
1095 {
1096 {
1097 {
1098 0x0000000000000000ULL,
1099 0x0000000000000000ULL,
1100 0x0000000000000000ULL,
1101 0x0000000000000000ULL,
1102 0x0000000000000000ULL,
1103 0x0000000000000000ULL,
1104 0x0000000000000000ULL,
1105 0x0000000000000000ULL
1106 },
1107 {
1108 0xFD00000000000000ULL,
1109 0x0000000000000000ULL,
1110 0x0000000000000000ULL,
1111 0x0000000000000000ULL,
1112 0x0000000000000000ULL,
1113 0x0000000000000000ULL,
1114 0x0000000000000000ULL,
1115 0x0000000000000000ULL
1116 },
1117 {
1118 0xFDFD000000000000ULL,
1119 0xFD00000000000000ULL,
1120 0x0000000000000000ULL,
1121 0x0000000000000000ULL,
1122 0x0000000000000000ULL,
1123 0x0000000000000000ULL,
1124 0x0000000000000000ULL,
1125 0x0000000000000000ULL
1126 },
1127 {
1128 0xFDFDFD0000000000ULL,
1129 0xFDFD000000000000ULL,
1130 0xFD00000000000000ULL,
1131 0x0000000000000000ULL,
1132 0x0000000000000000ULL,
1133 0x0000000000000000ULL,
1134 0x0000000000000000ULL,
1135 0x0000000000000000ULL
1136 },
1137 {
1138 0xFDFDFDFD00000000ULL,
1139 0xFDFDFD0000000000ULL,
1140 0xFDFD000000000000ULL,
1141 0xFD00000000000000ULL,
1142 0x0000000000000000ULL,
1143 0x0000000000000000ULL,
1144 0x0000000000000000ULL,
1145 0x0000000000000000ULL
1146 },
1147 {
1148 0xFDFDFDFDFD000000ULL,
1149 0xFDFDFDFD00000000ULL,
1150 0xFDFDFD0000000000ULL,
1151 0xFDFD000000000000ULL,
1152 0xFD00000000000000ULL,
1153 0x0000000000000000ULL,
1154 0x0000000000000000ULL,
1155 0x0000000000000000ULL
1156 },
1157 {
1158 0xFDFDFDFDFDFD0000ULL,
1159 0xFDFDFDFDFD000000ULL,
1160 0xFDFDFDFD00000000ULL,
1161 0xFDFDFD0000000000ULL,
1162 0xFDFD000000000000ULL,
1163 0xFD00000000000000ULL,
1164 0x0000000000000000ULL,
1165 0x0000000000000000ULL
1166 },
1167 {
1168 0xFDFDFDFDFDFDFD00ULL,
1169 0xFDFDFDFDFDFD0000ULL,
1170 0xFDFDFDFDFD000000ULL,
1171 0xFDFDFDFD00000000ULL,
1172 0xFDFDFD0000000000ULL,
1173 0xFDFD000000000000ULL,
1174 0xFD00000000000000ULL,
1175 0x0000000000000000ULL
1176 },
1177 {
1178 0xFDFDFDFDFDFDFDFDULL,
1179 0xFDFDFDFDFDFDFD00ULL,
1180 0xFDFDFDFDFDFD0000ULL,
1181 0xFDFDFDFDFD000000ULL,
1182 0xFDFDFDFD00000000ULL,
1183 0xFDFDFD0000000000ULL,
1184 0xFDFD000000000000ULL,
1185 0xFD00000000000000ULL
1186 },
1187 {
1188 0xFDFDFDFDFDFDFDFDULL,
1189 0xFDFDFDFDFDFDFDFDULL,
1190 0xFDFDFDFDFDFDFD00ULL,
1191 0xFDFDFDFDFDFD0000ULL,
1192 0xFDFDFDFDFD000000ULL,
1193 0xFDFDFDFD00000000ULL,
1194 0xFDFDFD0000000000ULL,
1195 0xFDFD000000000000ULL
1196 },
1197 {
1198 0xFDFDFDFDFDFDFDFDULL,
1199 0xFDFDFDFDFDFDFDFDULL,
1200 0xFDFDFDFDFDFDFDFDULL,
1201 0xFDFDFDFDFDFDFD00ULL,
1202 0xFDFDFDFDFDFD0000ULL,
1203 0xFDFDFDFDFD000000ULL,
1204 0xFDFDFDFD00000000ULL,
1205 0xFDFDFD0000000000ULL
1206 },
1207 {
1208 0xFDFDFDFDFDFDFDFDULL,
1209 0xFDFDFDFDFDFDFDFDULL,
1210 0xFDFDFDFDFDFDFDFDULL,
1211 0xFDFDFDFDFDFDFDFDULL,
1212 0xFDFDFDFDFDFDFD00ULL,
1213 0xFDFDFDFDFDFD0000ULL,
1214 0xFDFDFDFDFD000000ULL,
1215 0xFDFDFDFD00000000ULL
1216 },
1217 {
1218 0xFDFDFDFDFDFDFDFDULL,
1219 0xFDFDFDFDFDFDFDFDULL,
1220 0xFDFDFDFDFDFDFDFDULL,
1221 0xFDFDFDFDFDFDFDFDULL,
1222 0xFDFDFDFDFDFDFDFDULL,
1223 0xFDFDFDFDFDFDFD00ULL,
1224 0xFDFDFDFDFDFD0000ULL,
1225 0xFDFDFDFDFD000000ULL
1226 },
1227 {
1228 0xFDFDFDFDFDFDFDFDULL,
1229 0xFDFDFDFDFDFDFDFDULL,
1230 0xFDFDFDFDFDFDFDFDULL,
1231 0xFDFDFDFDFDFDFDFDULL,
1232 0xFDFDFDFDFDFDFDFDULL,
1233 0xFDFDFDFDFDFDFDFDULL,
1234 0xFDFDFDFDFDFDFD00ULL,
1235 0xFDFDFDFDFDFD0000ULL
1236 },
1237 {
1238 0xFDFDFDFDFDFDFDFDULL,
1239 0xFDFDFDFDFDFDFDFDULL,
1240 0xFDFDFDFDFDFDFDFDULL,
1241 0xFDFDFDFDFDFDFDFDULL,
1242 0xFDFDFDFDFDFDFDFDULL,
1243 0xFDFDFDFDFDFDFDFDULL,
1244 0xFDFDFDFDFDFDFDFDULL,
1245 0xFDFDFDFDFDFDFD00ULL
1246 },
1247 {
1248 0xFDFDFDFDFDFDFDFDULL,
1249 0xFDFDFDFDFDFDFDFDULL,
1250 0xFDFDFDFDFDFDFDFDULL,
1251 0xFDFDFDFDFDFDFDFDULL,
1252 0xFDFDFDFDFDFDFDFDULL,
1253 0xFDFDFDFDFDFDFDFDULL,
1254 0xFDFDFDFDFDFDFDFDULL,
1255 0xFDFDFDFDFDFDFDFDULL
1256 }
1257 },
1258 {
1259 {
1260 0x0000000000000000ULL,
1261 0x0000000000000000ULL,
1262 0x0000000000000000ULL,
1263 0x0000000000000000ULL,
1264 0x0000000000000000ULL,
1265 0x0000000000000000ULL,
1266 0x0000000000000000ULL,
1267 0x0000000000000000ULL
1268 },
1269 {
1270 0x00000000000000FDULL,
1271 0x0000000000000000ULL,
1272 0x0000000000000000ULL,
1273 0x0000000000000000ULL,
1274 0x0000000000000000ULL,
1275 0x0000000000000000ULL,
1276 0x0000000000000000ULL,
1277 0x0000000000000000ULL
1278 },
1279 {
1280 0x000000000000FDFDULL,
1281 0x00000000000000FDULL,
1282 0x0000000000000000ULL,
1283 0x0000000000000000ULL,
1284 0x0000000000000000ULL,
1285 0x0000000000000000ULL,
1286 0x0000000000000000ULL,
1287 0x0000000000000000ULL
1288 },
1289 {
1290 0x0000000000FDFDFDULL,
1291 0x000000000000FDFDULL,
1292 0x00000000000000FDULL,
1293 0x0000000000000000ULL,
1294 0x0000000000000000ULL,
1295 0x0000000000000000ULL,
1296 0x0000000000000000ULL,
1297 0x0000000000000000ULL
1298 },
1299 {
1300 0x00000000FDFDFDFDULL,
1301 0x0000000000FDFDFDULL,
1302 0x000000000000FDFDULL,
1303 0x00000000000000FDULL,
1304 0x0000000000000000ULL,
1305 0x0000000000000000ULL,
1306 0x0000000000000000ULL,
1307 0x0000000000000000ULL
1308 },
1309 {
1310 0x000000FDFDFDFDFDULL,
1311 0x00000000FDFDFDFDULL,
1312 0x0000000000FDFDFDULL,
1313 0x000000000000FDFDULL,
1314 0x00000000000000FDULL,
1315 0x0000000000000000ULL,
1316 0x0000000000000000ULL,
1317 0x0000000000000000ULL
1318 },
1319 {
1320 0x0000FDFDFDFDFDFDULL,
1321 0x000000FDFDFDFDFDULL,
1322 0x00000000FDFDFDFDULL,
1323 0x0000000000FDFDFDULL,
1324 0x000000000000FDFDULL,
1325 0x00000000000000FDULL,
1326 0x0000000000000000ULL,
1327 0x0000000000000000ULL
1328 },
1329 {
1330 0x00FDFDFDFDFDFDFDULL,
1331 0x0000FDFDFDFDFDFDULL,
1332 0x000000FDFDFDFDFDULL,
1333 0x00000000FDFDFDFDULL,
1334 0x0000000000FDFDFDULL,
1335 0x000000000000FDFDULL,
1336 0x00000000000000FDULL,
1337 0x0000000000000000ULL
1338 },
1339 {
1340 0xFDFDFDFDFDFDFDFDULL,
1341 0x00FDFDFDFDFDFDFDULL,
1342 0x0000FDFDFDFDFDFDULL,
1343 0x000000FDFDFDFDFDULL,
1344 0x00000000FDFDFDFDULL,
1345 0x0000000000FDFDFDULL,
1346 0x000000000000FDFDULL,
1347 0x00000000000000FDULL
1348 },
1349 {
1350 0xFDFDFDFDFDFDFDFDULL,
1351 0xFDFDFDFDFDFDFDFDULL,
1352 0x00FDFDFDFDFDFDFDULL,
1353 0x0000FDFDFDFDFDFDULL,
1354 0x000000FDFDFDFDFDULL,
1355 0x00000000FDFDFDFDULL,
1356 0x0000000000FDFDFDULL,
1357 0x000000000000FDFDULL
1358 },
1359 {
1360 0xFDFDFDFDFDFDFDFDULL,
1361 0xFDFDFDFDFDFDFDFDULL,
1362 0xFDFDFDFDFDFDFDFDULL,
1363 0x00FDFDFDFDFDFDFDULL,
1364 0x0000FDFDFDFDFDFDULL,
1365 0x000000FDFDFDFDFDULL,
1366 0x00000000FDFDFDFDULL,
1367 0x0000000000FDFDFDULL
1368 },
1369 {
1370 0xFDFDFDFDFDFDFDFDULL,
1371 0xFDFDFDFDFDFDFDFDULL,
1372 0xFDFDFDFDFDFDFDFDULL,
1373 0xFDFDFDFDFDFDFDFDULL,
1374 0x00FDFDFDFDFDFDFDULL,
1375 0x0000FDFDFDFDFDFDULL,
1376 0x000000FDFDFDFDFDULL,
1377 0x00000000FDFDFDFDULL
1378 },
1379 {
1380 0xFDFDFDFDFDFDFDFDULL,
1381 0xFDFDFDFDFDFDFDFDULL,
1382 0xFDFDFDFDFDFDFDFDULL,
1383 0xFDFDFDFDFDFDFDFDULL,
1384 0xFDFDFDFDFDFDFDFDULL,
1385 0x00FDFDFDFDFDFDFDULL,
1386 0x0000FDFDFDFDFDFDULL,
1387 0x000000FDFDFDFDFDULL
1388 },
1389 {
1390 0xFDFDFDFDFDFDFDFDULL,
1391 0xFDFDFDFDFDFDFDFDULL,
1392 0xFDFDFDFDFDFDFDFDULL,
1393 0xFDFDFDFDFDFDFDFDULL,
1394 0xFDFDFDFDFDFDFDFDULL,
1395 0xFDFDFDFDFDFDFDFDULL,
1396 0x00FDFDFDFDFDFDFDULL,
1397 0x0000FDFDFDFDFDFDULL
1398 },
1399 {
1400 0xFDFDFDFDFDFDFDFDULL,
1401 0xFDFDFDFDFDFDFDFDULL,
1402 0xFDFDFDFDFDFDFDFDULL,
1403 0xFDFDFDFDFDFDFDFDULL,
1404 0xFDFDFDFDFDFDFDFDULL,
1405 0xFDFDFDFDFDFDFDFDULL,
1406 0xFDFDFDFDFDFDFDFDULL,
1407 0x00FDFDFDFDFDFDFDULL
1408 },
1409 {
1410 0xFDFDFDFDFDFDFDFDULL,
1411 0xFDFDFDFDFDFDFDFDULL,
1412 0xFDFDFDFDFDFDFDFDULL,
1413 0xFDFDFDFDFDFDFDFDULL,
1414 0xFDFDFDFDFDFDFDFDULL,
1415 0xFDFDFDFDFDFDFDFDULL,
1416 0xFDFDFDFDFDFDFDFDULL,
1417 0xFDFDFDFDFDFDFDFDULL
1418 }
1419 },
1420 {
1421 {
1422 0x0000000000000000ULL,
1423 0x0000000000000000ULL,
1424 0x0000000000000000ULL,
1425 0x0000000000000000ULL,
1426 0x0000000000000000ULL,
1427 0x0000000000000000ULL,
1428 0x0000000000000000ULL,
1429 0x0000000000000000ULL
1430 },
1431 {
1432 0x0000000000000000ULL,
1433 0x0000000000000000ULL,
1434 0x0000000000000000ULL,
1435 0x0000000000000000ULL,
1436 0x0000000000000000ULL,
1437 0x0000000000000000ULL,
1438 0x0000000000000000ULL,
1439 0xFD00000000000000ULL
1440 },
1441 {
1442 0x0000000000000000ULL,
1443 0x0000000000000000ULL,
1444 0x0000000000000000ULL,
1445 0x0000000000000000ULL,
1446 0x0000000000000000ULL,
1447 0x0000000000000000ULL,
1448 0xFD00000000000000ULL,
1449 0xFDFD000000000000ULL
1450 },
1451 {
1452 0x0000000000000000ULL,
1453 0x0000000000000000ULL,
1454 0x0000000000000000ULL,
1455 0x0000000000000000ULL,
1456 0x0000000000000000ULL,
1457 0xFD00000000000000ULL,
1458 0xFDFD000000000000ULL,
1459 0xFDFDFD0000000000ULL
1460 },
1461 {
1462 0x0000000000000000ULL,
1463 0x0000000000000000ULL,
1464 0x0000000000000000ULL,
1465 0x0000000000000000ULL,
1466 0xFD00000000000000ULL,
1467 0xFDFD000000000000ULL,
1468 0xFDFDFD0000000000ULL,
1469 0xFDFDFDFD00000000ULL
1470 },
1471 {
1472 0x0000000000000000ULL,
1473 0x0000000000000000ULL,
1474 0x0000000000000000ULL,
1475 0xFD00000000000000ULL,
1476 0xFDFD000000000000ULL,
1477 0xFDFDFD0000000000ULL,
1478 0xFDFDFDFD00000000ULL,
1479 0xFDFDFDFDFD000000ULL
1480 },
1481 {
1482 0x0000000000000000ULL,
1483 0x0000000000000000ULL,
1484 0xFD00000000000000ULL,
1485 0xFDFD000000000000ULL,
1486 0xFDFDFD0000000000ULL,
1487 0xFDFDFDFD00000000ULL,
1488 0xFDFDFDFDFD000000ULL,
1489 0xFDFDFDFDFDFD0000ULL
1490 },
1491 {
1492 0x0000000000000000ULL,
1493 0xFD00000000000000ULL,
1494 0xFDFD000000000000ULL,
1495 0xFDFDFD0000000000ULL,
1496 0xFDFDFDFD00000000ULL,
1497 0xFDFDFDFDFD000000ULL,
1498 0xFDFDFDFDFDFD0000ULL,
1499 0xFDFDFDFDFDFDFD00ULL
1500 },
1501 {
1502 0xFD00000000000000ULL,
1503 0xFDFD000000000000ULL,
1504 0xFDFDFD0000000000ULL,
1505 0xFDFDFDFD00000000ULL,
1506 0xFDFDFDFDFD000000ULL,
1507 0xFDFDFDFDFDFD0000ULL,
1508 0xFDFDFDFDFDFDFD00ULL,
1509 0xFDFDFDFDFDFDFDFDULL
1510 },
1511 {
1512 0xFDFD000000000000ULL,
1513 0xFDFDFD0000000000ULL,
1514 0xFDFDFDFD00000000ULL,
1515 0xFDFDFDFDFD000000ULL,
1516 0xFDFDFDFDFDFD0000ULL,
1517 0xFDFDFDFDFDFDFD00ULL,
1518 0xFDFDFDFDFDFDFDFDULL,
1519 0xFDFDFDFDFDFDFDFDULL
1520 },
1521 {
1522 0xFDFDFD0000000000ULL,
1523 0xFDFDFDFD00000000ULL,
1524 0xFDFDFDFDFD000000ULL,
1525 0xFDFDFDFDFDFD0000ULL,
1526 0xFDFDFDFDFDFDFD00ULL,
1527 0xFDFDFDFDFDFDFDFDULL,
1528 0xFDFDFDFDFDFDFDFDULL,
1529 0xFDFDFDFDFDFDFDFDULL
1530 },
1531 {
1532 0xFDFDFDFD00000000ULL,
1533 0xFDFDFDFDFD000000ULL,
1534 0xFDFDFDFDFDFD0000ULL,
1535 0xFDFDFDFDFDFDFD00ULL,
1536 0xFDFDFDFDFDFDFDFDULL,
1537 0xFDFDFDFDFDFDFDFDULL,
1538 0xFDFDFDFDFDFDFDFDULL,
1539 0xFDFDFDFDFDFDFDFDULL
1540 },
1541 {
1542 0xFDFDFDFDFD000000ULL,
1543 0xFDFDFDFDFDFD0000ULL,
1544 0xFDFDFDFDFDFDFD00ULL,
1545 0xFDFDFDFDFDFDFDFDULL,
1546 0xFDFDFDFDFDFDFDFDULL,
1547 0xFDFDFDFDFDFDFDFDULL,
1548 0xFDFDFDFDFDFDFDFDULL,
1549 0xFDFDFDFDFDFDFDFDULL
1550 },
1551 {
1552 0xFDFDFDFDFDFD0000ULL,
1553 0xFDFDFDFDFDFDFD00ULL,
1554 0xFDFDFDFDFDFDFDFDULL,
1555 0xFDFDFDFDFDFDFDFDULL,
1556 0xFDFDFDFDFDFDFDFDULL,
1557 0xFDFDFDFDFDFDFDFDULL,
1558 0xFDFDFDFDFDFDFDFDULL,
1559 0xFDFDFDFDFDFDFDFDULL
1560 },
1561 {
1562 0xFDFDFDFDFDFDFD00ULL,
1563 0xFDFDFDFDFDFDFDFDULL,
1564 0xFDFDFDFDFDFDFDFDULL,
1565 0xFDFDFDFDFDFDFDFDULL,
1566 0xFDFDFDFDFDFDFDFDULL,
1567 0xFDFDFDFDFDFDFDFDULL,
1568 0xFDFDFDFDFDFDFDFDULL,
1569 0xFDFDFDFDFDFDFDFDULL
1570 },
1571 {
1572 0xFDFDFDFDFDFDFDFDULL,
1573 0xFDFDFDFDFDFDFDFDULL,
1574 0xFDFDFDFDFDFDFDFDULL,
1575 0xFDFDFDFDFDFDFDFDULL,
1576 0xFDFDFDFDFDFDFDFDULL,
1577 0xFDFDFDFDFDFDFDFDULL,
1578 0xFDFDFDFDFDFDFDFDULL,
1579 0xFDFDFDFDFDFDFDFDULL
1580 }
1581 },
1582 {
1583 {
1584 0x0000000000000000ULL,
1585 0x0000000000000000ULL,
1586 0x0000000000000000ULL,
1587 0x0000000000000000ULL,
1588 0x0000000000000000ULL,
1589 0x0000000000000000ULL,
1590 0x0000000000000000ULL,
1591 0x0000000000000000ULL
1592 },
1593 {
1594 0x0000000000000000ULL,
1595 0x0000000000000000ULL,
1596 0x0000000000000000ULL,
1597 0x0000000000000000ULL,
1598 0x0000000000000000ULL,
1599 0x0000000000000000ULL,
1600 0x0000000000000000ULL,
1601 0x00000000000000FDULL
1602 },
1603 {
1604 0x0000000000000000ULL,
1605 0x0000000000000000ULL,
1606 0x0000000000000000ULL,
1607 0x0000000000000000ULL,
1608 0x0000000000000000ULL,
1609 0x0000000000000000ULL,
1610 0x00000000000000FDULL,
1611 0x000000000000FDFDULL
1612 },
1613 {
1614 0x0000000000000000ULL,
1615 0x0000000000000000ULL,
1616 0x0000000000000000ULL,
1617 0x0000000000000000ULL,
1618 0x0000000000000000ULL,
1619 0x00000000000000FDULL,
1620 0x000000000000FDFDULL,
1621 0x0000000000FDFDFDULL
1622 },
1623 {
1624 0x0000000000000000ULL,
1625 0x0000000000000000ULL,
1626 0x0000000000000000ULL,
1627 0x0000000000000000ULL,
1628 0x00000000000000FDULL,
1629 0x000000000000FDFDULL,
1630 0x0000000000FDFDFDULL,
1631 0x00000000FDFDFDFDULL
1632 },
1633 {
1634 0x0000000000000000ULL,
1635 0x0000000000000000ULL,
1636 0x0000000000000000ULL,
1637 0x00000000000000FDULL,
1638 0x000000000000FDFDULL,
1639 0x0000000000FDFDFDULL,
1640 0x00000000FDFDFDFDULL,
1641 0x000000FDFDFDFDFDULL
1642 },
1643 {
1644 0x0000000000000000ULL,
1645 0x0000000000000000ULL,
1646 0x00000000000000FDULL,
1647 0x000000000000FDFDULL,
1648 0x0000000000FDFDFDULL,
1649 0x00000000FDFDFDFDULL,
1650 0x000000FDFDFDFDFDULL,
1651 0x0000FDFDFDFDFDFDULL
1652 },
1653 {
1654 0x0000000000000000ULL,
1655 0x00000000000000FDULL,
1656 0x000000000000FDFDULL,
1657 0x0000000000FDFDFDULL,
1658 0x00000000FDFDFDFDULL,
1659 0x000000FDFDFDFDFDULL,
1660 0x0000FDFDFDFDFDFDULL,
1661 0x00FDFDFDFDFDFDFDULL
1662 },
1663 {
1664 0x00000000000000FDULL,
1665 0x000000000000FDFDULL,
1666 0x0000000000FDFDFDULL,
1667 0x00000000FDFDFDFDULL,
1668 0x000000FDFDFDFDFDULL,
1669 0x0000FDFDFDFDFDFDULL,
1670 0x00FDFDFDFDFDFDFDULL,
1671 0xFDFDFDFDFDFDFDFDULL
1672 },
1673 {
1674 0x000000000000FDFDULL,
1675 0x0000000000FDFDFDULL,
1676 0x00000000FDFDFDFDULL,
1677 0x000000FDFDFDFDFDULL,
1678 0x0000FDFDFDFDFDFDULL,
1679 0x00FDFDFDFDFDFDFDULL,
1680 0xFDFDFDFDFDFDFDFDULL,
1681 0xFDFDFDFDFDFDFDFDULL
1682 },
1683 {
1684 0x0000000000FDFDFDULL,
1685 0x00000000FDFDFDFDULL,
1686 0x000000FDFDFDFDFDULL,
1687 0x0000FDFDFDFDFDFDULL,
1688 0x00FDFDFDFDFDFDFDULL,
1689 0xFDFDFDFDFDFDFDFDULL,
1690 0xFDFDFDFDFDFDFDFDULL,
1691 0xFDFDFDFDFDFDFDFDULL
1692 },
1693 {
1694 0x00000000FDFDFDFDULL,
1695 0x000000FDFDFDFDFDULL,
1696 0x0000FDFDFDFDFDFDULL,
1697 0x00FDFDFDFDFDFDFDULL,
1698 0xFDFDFDFDFDFDFDFDULL,
1699 0xFDFDFDFDFDFDFDFDULL,
1700 0xFDFDFDFDFDFDFDFDULL,
1701 0xFDFDFDFDFDFDFDFDULL
1702 },
1703 {
1704 0x000000FDFDFDFDFDULL,
1705 0x0000FDFDFDFDFDFDULL,
1706 0x00FDFDFDFDFDFDFDULL,
1707 0xFDFDFDFDFDFDFDFDULL,
1708 0xFDFDFDFDFDFDFDFDULL,
1709 0xFDFDFDFDFDFDFDFDULL,
1710 0xFDFDFDFDFDFDFDFDULL,
1711 0xFDFDFDFDFDFDFDFDULL
1712 },
1713 {
1714 0x0000FDFDFDFDFDFDULL,
1715 0x00FDFDFDFDFDFDFDULL,
1716 0xFDFDFDFDFDFDFDFDULL,
1717 0xFDFDFDFDFDFDFDFDULL,
1718 0xFDFDFDFDFDFDFDFDULL,
1719 0xFDFDFDFDFDFDFDFDULL,
1720 0xFDFDFDFDFDFDFDFDULL,
1721 0xFDFDFDFDFDFDFDFDULL
1722 },
1723 {
1724 0x00FDFDFDFDFDFDFDULL,
1725 0xFDFDFDFDFDFDFDFDULL,
1726 0xFDFDFDFDFDFDFDFDULL,
1727 0xFDFDFDFDFDFDFDFDULL,
1728 0xFDFDFDFDFDFDFDFDULL,
1729 0xFDFDFDFDFDFDFDFDULL,
1730 0xFDFDFDFDFDFDFDFDULL,
1731 0xFDFDFDFDFDFDFDFDULL
1732 },
1733 {
1734 0xFDFDFDFDFDFDFDFDULL,
1735 0xFDFDFDFDFDFDFDFDULL,
1736 0xFDFDFDFDFDFDFDFDULL,
1737 0xFDFDFDFDFDFDFDFDULL,
1738 0xFDFDFDFDFDFDFDFDULL,
1739 0xFDFDFDFDFDFDFDFDULL,
1740 0xFDFDFDFDFDFDFDFDULL,
1741 0xFDFDFDFDFDFDFDFDULL
1742 }
1743 }
1744 };
1745
1746 int32_t black_opening_count=0;
1747 int32_t black_opening_x,black_opening_y;
1748 int32_t black_opening_shape;
1749
1750 1506 int32_t choose_opening_shape()
1751 {
1752 // First, count how many bits are set
1753 1506 int32_t numBits=0;
1754 int32_t bitCounter;
1755
1756
2/2
✓ Branch 0 taken 7530 times.
✓ Branch 1 taken 1506 times.
9036 for(int32_t i=0; i<bosMAX; i++)
1757 {
1758
2/2
✓ Branch 0 taken 5808 times.
✓ Branch 1 taken 1722 times.
7530 if(COOLSCROLL&(1<<i))
1759 1722 numBits++;
1760 7530 }
1761
1762 // Shouldn't happen...
1763
1/2
✓ Branch 0 taken 1506 times.
✗ Branch 1 not taken.
1506 if(numBits==0)
1764 return bosCIRCLE;
1765
1766 // Pick a bit
1767 1506 bitCounter=zc_rand()%numBits+1;
1768
1769
2/2
✓ Branch 0 taken 1991 times.
✓ Branch 1 taken 26 times.
2017 for(int32_t i=0; i<bosMAX; i++)
1770 {
1771 // If this bit is set, decrement the bit counter
1772
2/2
✓ Branch 0 taken 355 times.
✓ Branch 1 taken 1636 times.
1991 if(COOLSCROLL&(1<<i))
1773 1636 bitCounter--;
1774
1775 // When the counter hits 0, return a value based on
1776 // which bit it stopped on.
1777 // Reminder: enum {bosCIRCLE=0, bosOVAL, bosTRIANGLE, bosSMAS, bosFADEBLACK, bosMAX};
1778
2/2
✓ Branch 0 taken 1480 times.
✓ Branch 1 taken 511 times.
1991 if(bitCounter==0)
1779 1480 return i;
1780 511 }
1781
1782 // Shouldn't be necessary, but the compiler might complain, at least
1783 26 return bosCIRCLE;
1784 1506 }
1785
1786 396 void close_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1787 {
1788
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 396 times.
396 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1789
1790 396 int32_t w=256, h=224;
1791 396 int32_t blockrows=28, blockcolumns=32;
1792 396 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1793
1794
2/2
✓ Branch 0 taken 11088 times.
✓ Branch 1 taken 396 times.
11484 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1795 {
1796
2/2
✓ Branch 0 taken 354816 times.
✓ Branch 1 taken 11088 times.
365904 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1797 {
1798
2/2
✓ Branch 0 taken 188540 times.
✓ Branch 1 taken 166276 times.
354816 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1799 354816 }
1800 11088 }
1801
1802 396 black_opening_count = 66;
1803 396 black_opening_x = x;
1804 396 black_opening_y = y;
1805 396 lensclk = 0;
1806 //black_opening_shape=(black_opening_shape+1)%bosMAX;
1807
1808
1809
1/2
✓ Branch 0 taken 396 times.
✗ Branch 1 not taken.
396 if(black_opening_shape == bosFADEBLACK)
1810 {
1811 refreshTints();
1812 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1813 }
1814
1/2
✓ Branch 0 taken 396 times.
✗ Branch 1 not taken.
396 if(wait)
1815 {
1816 FFCore.warpScriptCheck();
1817 for(int32_t i=0; i<66; i++)
1818 {
1819 draw_screen(tmpscr);
1820 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
1821 advanceframe(true);
1822
1823 if(Quit)
1824 {
1825 break;
1826 }
1827 }
1828 }
1829 396 }
1830
1831 1110 void open_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1832 {
1833
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1110 times.
1110 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1834
1835 1110 int32_t w=256, h=224;
1836 1110 int32_t blockrows=28, blockcolumns=32;
1837 1110 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1838
1839
2/2
✓ Branch 0 taken 31080 times.
✓ Branch 1 taken 1110 times.
32190 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1840 {
1841
2/2
✓ Branch 0 taken 994560 times.
✓ Branch 1 taken 31080 times.
1025640 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1842 {
1843
2/2
✓ Branch 0 taken 442260 times.
✓ Branch 1 taken 552300 times.
994560 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1844 994560 }
1845 31080 }
1846
1847 1110 black_opening_count = -66;
1848 1110 black_opening_x = x;
1849 1110 black_opening_y = y;
1850 1110 lensclk = 0;
1851
1/2
✓ Branch 0 taken 1110 times.
✗ Branch 1 not taken.
1110 if(black_opening_shape == bosFADEBLACK)
1852 {
1853 refreshTints();
1854 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1855 }
1856
2/2
✓ Branch 0 taken 199 times.
✓ Branch 1 taken 911 times.
1110 if(wait)
1857 {
1858 911 FFCore.warpScriptCheck();
1859
2/2
✓ Branch 0 taken 911 times.
✓ Branch 1 taken 60126 times.
61037 for(int32_t i=0; i<66; i++)
1860 {
1861 60126 draw_screen(tmpscr);
1862 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
1863 60126 advanceframe(true);
1864
1865
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60126 times.
60126 if(Quit)
1866 {
1867 break;
1868 }
1869 60126 }
1870 911 }
1871 1110 }
1872
1873 99396 void black_opening(BITMAP *dest,int32_t x,int32_t y,int32_t a,int32_t max_a)
1874 {
1875 99396 clear_to_color(tmp_scr,BLACK);
1876 99396 int32_t w=256, h=224;
1877
1878
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 858 times.
✓ Branch 2 taken 660 times.
✓ Branch 3 taken 7656 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 90222 times.
99396 switch(black_opening_shape)
1879 {
1880 case bosOVAL:
1881 {
1882 858 double new_w=(w/2)+abs(w/2-x);
1883 858 double new_h=(h/2)+abs(h/2-y);
1884 858 double b=sqrt(((new_w*new_w)/4)+(new_h*new_h));
1885 858 ellipsefill(tmp_scr,x,y,int32_t(2*a*b/max_a)/8*8,int32_t(a*b/max_a)/8*8,0);
1886 858 break;
1887 }
1888
1889 case bosTRIANGLE:
1890 {
1891 660 double new_w=(w/2)+abs(w/2-x);
1892 660 double new_h=(h/2)+abs(h/2-y);
1893 660 double r=a*(new_w*sqrt((double)3)+new_h)/max_a;
1894 660 double P2= (PI/2);
1895 660 double P23=(2*PI/3);
1896 660 double P43=(4*PI/3);
1897 660 double Pa= (-4*PI*a/(3*max_a));
1898 660 double angle=P2+Pa;
1899 660 double a0=angle;
1900 660 double a2=angle+P23;
1901 660 double a4=angle+P43;
1902 1320 triangle(tmp_scr, x+int32_t(zc::math::Cos(a0)*r), y-int32_t(zc::math::Sin(a0)*r),
1903 660 x+int32_t(zc::math::Cos(a2)*r), y-int32_t(zc::math::Sin(a2)*r),
1904 660 x+int32_t(zc::math::Cos(a4)*r), y-int32_t(zc::math::Sin(a4)*r),
1905 0);
1906 660 break;
1907 }
1908
1909 case bosSMAS:
1910 {
1911
2/2
✓ Branch 0 taken 2838 times.
✓ Branch 1 taken 4818 times.
7656 int32_t distance=zc_max(abs(w/2-x),abs(h/2-y))/8;
1912
1913
2/2
✓ Branch 0 taken 214368 times.
✓ Branch 1 taken 7656 times.
222024 for(int32_t blockrow=0; blockrow<28; ++blockrow) //30
1914 {
1915
2/2
✓ Branch 0 taken 1714944 times.
✓ Branch 1 taken 214368 times.
1929312 for(int32_t linerow=0; linerow<8; ++linerow)
1916 {
1917 1714944 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1918
1919
2/2
✓ Branch 0 taken 54878208 times.
✓ Branch 1 taken 1714944 times.
56593152 for(int32_t blockcolumn=0; blockcolumn<32; ++blockcolumn) //40
1920 {
1921 164634624 *triangleline=triangles[(screen_triangles[blockrow][blockcolumn]&0xC000)>>14]
1922
6/6
✓ Branch 0 taken 38180568 times.
✓ Branch 1 taken 16697640 times.
✓ Branch 2 taken 35934032 times.
✓ Branch 3 taken 18944176 times.
✓ Branch 4 taken 19236392 times.
✓ Branch 5 taken 16697640 times.
54878208 [zc_min(zc_max((((31+distance)*(max_a-a)/max_a)+((screen_triangles[blockrow][blockcolumn]&0x0FFF)-0x0100)-(15+distance)),0),15)]
1923 54878208 [linerow];
1924 54878208 ++triangleline;
1925
1926
2/2
✓ Branch 0 taken 48018432 times.
✓ Branch 1 taken 6859776 times.
54878208 if(linerow==0)
1927 {
1928 6859776 }
1929 54878208 }
1930 1714944 }
1931 214368 }
1932
1933 7656 break;
1934 }
1935
1936 case bosFADEBLACK:
1937 {
1938 if(black_opening_count<0)
1939 {
1940 black_fade(zc_min(-black_opening_count,63));
1941 }
1942 else if(black_opening_count>0)
1943 {
1944 black_fade(63-zc_max(black_opening_count-3,0));
1945 }
1946 else black_fade(0);
1947 return; //no blitting from tmp_scr!
1948 }
1949
1950 90222 case bosCIRCLE:
1951 default:
1952 {
1953 90222 double new_w=(w/2)+abs(w/2-x);
1954 90222 double new_h=(h/2)+abs(h/2-y);
1955 90222 int32_t r=int32_t(sqrt((new_w*new_w)+(new_h*new_h))*a/max_a);
1956 //circlefill(tmp_scr,x,y,a<<3,0);
1957 90222 circlefill(tmp_scr,x,y,r,0);
1958 90222 break;
1959 }
1960 }
1961
1962 99396 masked_blit(tmp_scr,dest,0,0,0,0,320,240);
1963 99396 }
1964
1965
1966 void black_fade(int32_t fadeamnt)
1967 {
1968 for(int32_t i=0; i < 0xEF; i++)
1969 {
1970 RAMpal[i].r = vbound(tempblackpal[i].r-fadeamnt,0,63);
1971 RAMpal[i].g = vbound(tempblackpal[i].g-fadeamnt,0,63);
1972 RAMpal[i].b = vbound(tempblackpal[i].b-fadeamnt,0,63);
1973 }
1974
1975 refreshpal = true;
1976 }
1977
1978 //----------------------------------------------------------------
1979
1980 38813571 bool item_disabled(int32_t item) //is this item disabled?
1981 {
1982
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38813571 times.
38813571 return (unsigned(item) < MAXITEMS && game->items_off[item] != 0);
1983 }
1984
1985 7615632 bool can_use_item(int32_t item_type, int32_t item) //can Hero use this item?
1986 {
1987
2/2
✓ Branch 0 taken 135248 times.
✓ Branch 1 taken 7480384 times.
7615632 if(current_item(item_type, true) >=item)
1988 {
1989 135248 return true;
1990 }
1991
1992 7480384 return false;
1993 7615632 }
1994
1995 30661739 bool has_item(int32_t item_type, int32_t it) //does Hero possess this item?
1996 {
1997
5/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 6051811 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3220277 times.
✓ Branch 6 taken 16010221 times.
✓ Branch 7 taken 5337683 times.
✓ Branch 8 taken 41747 times.
30661739 switch(item_type)
1998 {
1999 case itype_bomb:
2000 case itype_sbomb:
2001 {
2002 int32_t itemid = getItemID(itemsbuf, item_type, it);
2003
2004 if(itemid == -1)
2005 return false;
2006
2007 return (game->get_item(itemid));
2008 }
2009
2010 case itype_clock:
2011 {
2012 6051811 int32_t itemid = getItemID(itemsbuf, item_type, it);
2013
2014
2/4
✓ Branch 0 taken 6051811 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6051811 times.
✗ Branch 3 not taken.
6051811 if(itemid != -1 && (itemsbuf[itemid].flags & ITEM_FLAG1)) //Active clock
2015 return (game->get_item(itemid));
2016 6051811 return Hero.getClock()?1:0;
2017 }
2018
2019 case itype_key:
2020 return (game->get_keys()>0);
2021
2022 case itype_magiccontainer:
2023 return (game->get_maxmagic()>=game->get_mp_per_block());
2024
2025 case itype_triforcepiece: //it: -2=any, -1=current level, other=that level
2026 {
2027
1/3
✓ Branch 0 taken 3220277 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
3220277 switch(it)
2028 {
2029 case -2:
2030 {
2031 for(int32_t i=0; i<MAXLEVELS; i++)
2032 {
2033 if(game->lvlitems[i]&liTRIFORCE)
2034 {
2035 return true;
2036 }
2037 }
2038
2039 return false;
2040 }
2041
2042 case -1:
2043 return (game->lvlitems[dlevel]&liTRIFORCE);
2044
2045 default:
2046
2/4
✓ Branch 0 taken 3220277 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3220277 times.
3220277 if(it>=0&&it<MAXLEVELS)
2047 {
2048 3220277 return (game->lvlitems[it]&liTRIFORCE);
2049 }
2050
2051 break;
2052 }
2053
2054 return 0;
2055 }
2056
2057 case itype_map: //it: -2=any, -1=current level, other=that level
2058 {
2059
1/3
✓ Branch 0 taken 16010221 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
16010221 switch(it)
2060 {
2061 case -2:
2062 {
2063 for(int32_t i=0; i<MAXLEVELS; i++)
2064 {
2065 if(game->lvlitems[i]&liMAP)
2066 {
2067 return true;
2068 }
2069 }
2070
2071 return false;
2072 }
2073
2074 case -1:
2075 return (game->lvlitems[dlevel]&liMAP)!=0;
2076
2077 default:
2078
2/4
✓ Branch 0 taken 16010221 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 16010221 times.
16010221 if(it>=0&&it<MAXLEVELS)
2079 {
2080 16010221 return (game->lvlitems[it]&liMAP)!=0;
2081 }
2082
2083 break;
2084 }
2085
2086 return 0;
2087 }
2088
2089 case itype_compass: //it: -2=any, -1=current level, other=that level
2090 {
2091
1/3
✓ Branch 0 taken 5337683 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
5337683 switch(it)
2092 {
2093 case -2:
2094 {
2095 for(int32_t i=0; i<MAXLEVELS; i++)
2096 {
2097 if(game->lvlitems[i]&liCOMPASS)
2098 {
2099 return true;
2100 }
2101 }
2102
2103 return false;
2104 }
2105
2106 case -1:
2107 return (game->lvlitems[dlevel]&liCOMPASS)!=0;
2108
2109 default:
2110
2/4
✓ Branch 0 taken 5337683 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5337683 times.
✗ Branch 3 not taken.
5337683 if(it>=0&&it<MAXLEVELS)
2111 {
2112 5337683 return (game->lvlitems[it]&liCOMPASS)!=0;
2113 }
2114
2115 break;
2116 }
2117 return 0;
2118 }
2119
2120 case itype_bosskey: //it: -2=any, -1=current level, other=that level
2121 {
2122
1/3
✓ Branch 0 taken 41747 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
41747 switch(it)
2123 {
2124 case -2:
2125 {
2126 for(int32_t i=0; i<MAXLEVELS; i++)
2127 {
2128 if(game->lvlitems[i]&liBOSSKEY)
2129 {
2130 return true;
2131 }
2132 }
2133
2134 return false;
2135 }
2136
2137 case -1:
2138 return (game->lvlitems[dlevel]&liBOSSKEY)?1:0;
2139
2140 default:
2141
2/4
✓ Branch 0 taken 41747 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 41747 times.
41747 if(it>=0&&it<MAXLEVELS)
2142 {
2143 41747 return (game->lvlitems[it]&liBOSSKEY)?1:0;
2144 }
2145 break;
2146 }
2147 return 0;
2148 }
2149
2150 default:
2151 //it=(1<<(it-1));
2152 /*if (item_type>=itype_max)
2153 {
2154 enter_sys_pal();
2155 jwin_alert("Error","has_item exception",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2156 exit_sys_pal();
2157
2158 return false;
2159 }*/
2160 int32_t itemid = getItemID(itemsbuf, item_type, it);
2161
2162 if(itemid == -1)
2163 return false;
2164
2165 return game->get_item(itemid);
2166 }
2167 30661739 }
2168
2169
2170 99990255 int32_t current_item(int32_t item_type, bool checkenabled) //item currently being used
2171 {
2172
9/9
✓ Branch 0 taken 6051811 times.
✓ Branch 1 taken 51575767 times.
✓ Branch 2 taken 6051811 times.
✓ Branch 3 taken 6051811 times.
✓ Branch 4 taken 6051811 times.
✓ Branch 5 taken 6051811 times.
✓ Branch 6 taken 6051811 times.
✓ Branch 7 taken 6051811 times.
✓ Branch 8 taken 6051811 times.
99990255 switch(item_type)
2173 {
2174 case itype_clock:
2175 {
2176 6051811 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2177
2178
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6051811 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6051811 if(maxid != -1 && (itemsbuf[maxid].flags & ITEM_FLAG1)) //Active clock
2179 return itemsbuf[maxid].fam_type;
2180
2181 6051811 return has_item(itype_clock,1) ? 1 : 0;
2182 }
2183
2184 case itype_key:
2185 6051811 return game->get_keys();
2186
2187 case itype_lkey:
2188 6051811 return game->lvlkeys[get_dlevel()];
2189
2190 case itype_magiccontainer:
2191 6051811 return game->get_maxmagic()/game->get_mp_per_block();
2192
2193 case itype_triforcepiece:
2194 {
2195 6051811 int32_t count=0;
2196
2197
2/2
✓ Branch 0 taken 3098527232 times.
✓ Branch 1 taken 6051811 times.
3104579043 for(int32_t i=0; i<MAXLEVELS; i++)
2198 {
2199 3098527232 count+=(game->lvlitems[i]&liTRIFORCE)?1:0;
2200 3098527232 }
2201
2202 6051811 return count;
2203 }
2204
2205 case itype_map:
2206 {
2207 6051811 int32_t count=0;
2208
2209
2/2
✓ Branch 0 taken 3098527232 times.
✓ Branch 1 taken 6051811 times.
3104579043 for(int32_t i=0; i<MAXLEVELS; i++)
2210 {
2211 3098527232 count+=(game->lvlitems[i]&liMAP)?1:0;
2212 3098527232 }
2213
2214 6051811 return count;
2215 }
2216
2217 case itype_compass:
2218 {
2219 6051811 int32_t count=0;
2220
2221
2/2
✓ Branch 0 taken 3098527232 times.
✓ Branch 1 taken 6051811 times.
3104579043 for(int32_t i=0; i<MAXLEVELS; i++)
2222 {
2223 3098527232 count+=(game->lvlitems[i]&liCOMPASS)?1:0;
2224 3098527232 }
2225
2226 6051811 return count;
2227 }
2228
2229 case itype_bosskey:
2230 {
2231 6051811 int32_t count=0;
2232
2233
2/2
✓ Branch 0 taken 3098527232 times.
✓ Branch 1 taken 6051811 times.
3104579043 for(int32_t i=0; i<MAXLEVELS; i++)
2234 {
2235 3098527232 count+=(game->lvlitems[i]&liBOSSKEY)?1:0;
2236 3098527232 }
2237
2238 6051811 return count;
2239 }
2240
2241 default:
2242 51575767 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2243
2244
2/2
✓ Branch 0 taken 9877334 times.
✓ Branch 1 taken 41698433 times.
51575767 if(maxid == -1)
2245 41698433 return 0;
2246
2247 9877334 return itemsbuf[maxid].fam_type;
2248 }
2249 99990255 }
2250
2251 92374623 int32_t current_item(int32_t item_type) //item currently being used
2252 {
2253 92374623 return current_item(item_type, true);
2254 }
2255
2256 116 std::map<int32_t, int32_t> itemcache;
2257
2258 // Not actually used by anything at the moment...
2259 void removeFromItemCache(int32_t itemclass)
2260 {
2261 itemcache.erase(itemclass);
2262 }
2263
2264 30026 void flushItemCache()
2265 {
2266 30026 itemcache.clear();
2267
2268 //also fix the active subscreen if items were deleted -DD
2269
1/2
✓ Branch 0 taken 30026 times.
✗ Branch 1 not taken.
30026 if(game != NULL)
2270 {
2271 30026 verifyBothWeapons();
2272 30026 load_Sitems();
2273 30026 }
2274 30026 }
2275
2276 // This is used often, so it should be as direct as possible.
2277 3372133296 int32_t _c_item_id_internal(int32_t itemtype, bool checkmagic, bool jinx_check)
2278 {
2279
2/2
✓ Branch 0 taken 3296618299 times.
✓ Branch 1 taken 75514997 times.
3372133296 if(jinx_check)
2280 {
2281
4/4
✓ Branch 0 taken 47347658 times.
✓ Branch 1 taken 28167339 times.
✓ Branch 2 taken 39070031 times.
✓ Branch 3 taken 8277627 times.
75514997 if(!(HeroSwordClk() || HeroItemClk()))
2282 39070031 jinx_check = false; //not jinxed
2283 75514997 }
2284
4/4
✓ Branch 0 taken 3342722254 times.
✓ Branch 1 taken 29411042 times.
✓ Branch 2 taken 36112271 times.
✓ Branch 3 taken 3306609983 times.
3372133296 if(itemtype!=itype_ring && !jinx_check) // Rings must always be checked, as must jinx checks...
2285 {
2286 3306609983 std::map<int32_t,int32_t>::iterator res = itemcache.find(itemtype);
2287
2288
2/2
✓ Branch 0 taken 3291279715 times.
✓ Branch 1 taken 15330268 times.
3306609983 if(res != itemcache.end())
2289 3291279715 return res->second;
2290 15330268 }
2291
2292 80853581 int32_t result = -1;
2293 80853581 int32_t highestlevel = -1;
2294
2295
2/2
✓ Branch 0 taken 20698516736 times.
✓ Branch 1 taken 80853581 times.
20779370317 for(int32_t i=0; i<MAXITEMS; i++)
2296 {
2297
5/6
✓ Branch 0 taken 1517290847 times.
✓ Branch 1 taken 19181225889 times.
✓ Branch 2 taken 21721442 times.
✓ Branch 3 taken 1495569405 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 21721442 times.
20698516736 if(game->get_item(i) && itemsbuf[i].family==itemtype && !item_disabled(i))
2298 {
2299
4/4
✓ Branch 0 taken 5876352 times.
✓ Branch 1 taken 15845090 times.
✓ Branch 2 taken 1816039 times.
✓ Branch 3 taken 19905403 times.
21721442 if((checkmagic || itemtype == itype_ring) && itemtype != itype_magicring)
2300 {
2301 //printf("Checkmagic for %d: %d (%d %d)\n",i,checkmagiccost(i),itemsbuf[i].magic*game->get_magicdrainrate(),game->get_magic());
2302
2/2
✓ Branch 0 taken 19905230 times.
✓ Branch 1 taken 173 times.
19905403 if(!checkmagiccost(i))
2303 {
2304
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 161 times.
173 if ( !get_qr(qr_NEVERDISABLEAMMOONSUBSCREEN) ) continue; //don't make items with a magic cost vanish!! -Z
2305 12 }
2306 19905242 }
2307
6/6
✓ Branch 0 taken 18413039 times.
✓ Branch 1 taken 3308242 times.
✓ Branch 2 taken 311736 times.
✓ Branch 3 taken 2996506 times.
✓ Branch 4 taken 1799132 times.
✓ Branch 5 taken 1509110 times.
21721281 if(jinx_check && (usesSwordJinx(i) ? HeroSwordClk() : HeroItemClk()))
2308 {
2309
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1509110 times.
1509110 if(!(itemsbuf[i].flags & ITEM_JINX_IMMUNE))
2310 1509110 continue;
2311 }
2312
2313
2/2
✓ Branch 0 taken 278854 times.
✓ Branch 1 taken 19933317 times.
20212171 if(itemsbuf[i].fam_type >= highestlevel)
2314 {
2315 19933317 highestlevel = itemsbuf[i].fam_type;
2316 19933317 result=i;
2317 19933317 }
2318 20212171 }
2319 20697007465 }
2320
2321
2/2
✓ Branch 0 taken 36444966 times.
✓ Branch 1 taken 44408615 times.
80853581 if(!jinx_check) //Can't cache jinx_check results
2322 44408615 itemcache[itemtype] = result;
2323 80853581 return result;
2324 3372133296 }
2325
2326 // 'jinx_check' indicates that the highest level item *immune to jinxes* should be returned.
2327 3336132543 int32_t current_item_id(int32_t itemtype, bool checkmagic, bool jinx_check)
2328 {
2329 3336132543 auto ret = _c_item_id_internal(itemtype,checkmagic,jinx_check);
2330
2/2
✓ Branch 0 taken 39514244 times.
✓ Branch 1 taken 3296618299 times.
3336132543 if(!jinx_check) //If not already a jinx-immune-only check...
2331 {
2332 //And the player IS jinxed...
2333
4/4
✓ Branch 0 taken 3268793937 times.
✓ Branch 1 taken 27824362 times.
✓ Branch 2 taken 8176391 times.
✓ Branch 3 taken 3260617546 times.
3296618299 if(HeroSwordClk() || HeroItemClk())
2334 {
2335 //Then do a jinx-immune-only check here
2336 36000753 auto ret2 = _c_item_id_internal(itemtype,checkmagic,true);
2337 //And *IF IT FINDS A VALID ITEM*, return that one instead! -Em
2338 //Should NOT need a compat rule, as this should always return -1 in old quests.
2339
2/2
✓ Branch 0 taken 1216689 times.
✓ Branch 1 taken 34784064 times.
36000753 if(ret2 > -1) return ret2;
2340 34784064 }
2341 3295401610 }
2342 3334915854 return ret;
2343 3336132543 }
2344 19237880 int32_t current_item_power(int32_t itemtype)
2345 {
2346 19237880 int32_t result = current_item_id(itemtype,true);
2347
2/2
✓ Branch 0 taken 13950304 times.
✓ Branch 1 taken 5287576 times.
19237880 return (result<0) ? 0 : itemsbuf[result].power;
2348 }
2349
2350 11 int32_t heart_container_id()
2351 {
2352
1/2
✓ Branch 0 taken 319 times.
✗ Branch 1 not taken.
319 for(int32_t i=0; i<MAXITEMS; i++)
2353 {
2354
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 308 times.
319 if(itemsbuf[i].family == itype_heartcontainer)
2355 {
2356 11 return i;
2357 }
2358 308 }
2359 return -1;
2360 11 }
2361
2362 6051811 int32_t item_tile_mod()
2363 {
2364 6051811 int32_t tile=0;
2365
2366
2/2
✓ Branch 0 taken 1204800 times.
✓ Branch 1 taken 4847011 times.
6051811 if(game->get_bombs())
2367 {
2368 4847011 int32_t itemid = current_item_id(itype_bomb,false);
2369
3/4
✓ Branch 0 taken 4681842 times.
✓ Branch 1 taken 165169 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4681842 times.
4847011 if(itemid > -1 && checkbunny(itemid))
2370 4681842 tile+=itemsbuf[itemid].ltm;
2371 4847011 }
2372
2373
2/2
✓ Branch 0 taken 4537735 times.
✓ Branch 1 taken 1514076 times.
6051811 if(game->get_sbombs())
2374 {
2375 1514076 int32_t itemid = current_item_id(itype_sbomb,false);
2376
3/4
✓ Branch 0 taken 1512648 times.
✓ Branch 1 taken 1428 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1512648 times.
1514076 if(itemid > -1 && checkbunny(itemid))
2377 1512648 tile+=itemsbuf[itemid].ltm;
2378 1514076 }
2379
2380
2/2
✓ Branch 0 taken 5942111 times.
✓ Branch 1 taken 109700 times.
6051811 if(current_item(itype_clock))
2381 {
2382 109700 int32_t itemid =
2383
1/2
✓ Branch 0 taken 109700 times.
✗ Branch 1 not taken.
109700 get_qr(qr_HARDCODED_LITEM_LTMS)
2384 ? iClock
2385 : getHighestLevelEvenUnowned(itemsbuf, itype_clock);
2386
2/4
✓ Branch 0 taken 109700 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 109700 times.
109700 if(itemid > -1 && checkbunny(itemid))
2387 109700 tile+=itemsbuf[itemid].ltm;
2388 109700 }
2389
2390
2/2
✓ Branch 0 taken 4671070 times.
✓ Branch 1 taken 1380741 times.
6051811 if(current_item(itype_key))
2391 {
2392 1380741 int32_t itemid =
2393
1/2
✓ Branch 0 taken 1380741 times.
✗ Branch 1 not taken.
1380741 get_qr(qr_HARDCODED_LITEM_LTMS)
2394 ? iKey
2395 : getHighestLevelEvenUnowned(itemsbuf, itype_key);
2396
2/4
✓ Branch 0 taken 1380741 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1380741 times.
1380741 if(itemid > -1 && checkbunny(itemid))
2397 1380741 tile+=itemsbuf[itemid].ltm;
2398 1380741 }
2399
2400
2/2
✓ Branch 0 taken 5784708 times.
✓ Branch 1 taken 267103 times.
6051811 if(current_item(itype_lkey))
2401 {
2402 267103 int32_t itemid =
2403
2/2
✓ Branch 0 taken 266193 times.
✓ Branch 1 taken 910 times.
267103 get_qr(qr_HARDCODED_LITEM_LTMS)
2404 ? iLevelKey
2405 910 : getHighestLevelEvenUnowned(itemsbuf, itype_lkey);
2406
2/4
✓ Branch 0 taken 267103 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 267103 times.
267103 if(itemid > -1 && checkbunny(itemid))
2407 267103 tile+=itemsbuf[itemid].ltm;
2408 267103 }
2409
2410
2/2
✓ Branch 0 taken 1254994 times.
✓ Branch 1 taken 4796817 times.
6051811 if(current_item(itype_map))
2411 {
2412 4796817 int32_t itemid =
2413
2/2
✓ Branch 0 taken 4796031 times.
✓ Branch 1 taken 786 times.
4796817 get_qr(qr_HARDCODED_LITEM_LTMS)
2414 ? iMap
2415 786 : getHighestLevelEvenUnowned(itemsbuf, itype_map);
2416
2/4
✓ Branch 0 taken 4796817 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4796817 times.
4796817 if(itemid > -1 && checkbunny(itemid))
2417 4796817 tile+=itemsbuf[itemid].ltm;
2418 4796817 }
2419
2420
2/2
✓ Branch 0 taken 1233112 times.
✓ Branch 1 taken 4818699 times.
6051811 if(current_item(itype_compass))
2421 {
2422 4818699 int32_t itemid =
2423
2/2
✓ Branch 0 taken 4737640 times.
✓ Branch 1 taken 81059 times.
4818699 get_qr(qr_HARDCODED_LITEM_LTMS)
2424 ? iCompass
2425 81059 : getHighestLevelEvenUnowned(itemsbuf, itype_compass);
2426
2/4
✓ Branch 0 taken 4818699 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4818699 times.
4818699 if(itemid > -1 && checkbunny(itemid))
2427 4818699 tile+=itemsbuf[itemid].ltm;
2428 4818699 }
2429
2430
2/2
✓ Branch 0 taken 3421266 times.
✓ Branch 1 taken 2630545 times.
6051811 if(current_item(itype_bosskey))
2431 {
2432 2630545 int32_t itemid =
2433
1/2
✓ Branch 0 taken 2630545 times.
✗ Branch 1 not taken.
2630545 get_qr(qr_HARDCODED_LITEM_LTMS)
2434 ? iBossKey
2435 : getHighestLevelEvenUnowned(itemsbuf, itype_bosskey);
2436
2/4
✓ Branch 0 taken 2630545 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2630545 times.
2630545 if(itemid > -1 && checkbunny(itemid))
2437 2630545 tile+=itemsbuf[itemid].ltm;
2438 2630545 }
2439
2440
2/2
✓ Branch 0 taken 2917835 times.
✓ Branch 1 taken 3133976 times.
6051811 if(current_item(itype_magiccontainer))
2441 {
2442 3133976 int32_t itemid =
2443
2/2
✓ Branch 0 taken 3040989 times.
✓ Branch 1 taken 92987 times.
3133976 get_qr(qr_HARDCODED_LITEM_LTMS)
2444 ? iMagicC
2445 92987 : getHighestLevelEvenUnowned(itemsbuf, itype_magiccontainer);
2446
3/4
✓ Branch 0 taken 3133976 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1870 times.
✓ Branch 3 taken 3132106 times.
3133976 if(itemid > -1 && checkbunny(itemid))
2447 3132106 tile+=itemsbuf[itemid].ltm;
2448 3133976 }
2449
2450
2/2
✓ Branch 0 taken 1591177 times.
✓ Branch 1 taken 4460634 times.
6051811 if(current_item(itype_triforcepiece))
2451 {
2452 4460634 int32_t itemid =
2453
1/2
✓ Branch 0 taken 4460634 times.
✗ Branch 1 not taken.
4460634 get_qr(qr_HARDCODED_LITEM_LTMS)
2454 ? iTriforce
2455 : getHighestLevelEvenUnowned(itemsbuf, itype_triforcepiece);
2456
2/4
✓ Branch 0 taken 4460634 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4460634 times.
4460634 if(itemid > -1 && checkbunny(itemid))
2457 4460634 tile+=itemsbuf[itemid].ltm;
2458 4460634 }
2459
2460
2/2
✓ Branch 0 taken 6051811 times.
✓ Branch 1 taken 3098527232 times.
3104579043 for(int32_t i=0; i<itype_max; i++)
2461 {
2462
2/2
✓ Branch 0 taken 3042451456 times.
✓ Branch 1 taken 56075776 times.
3098527232 if(!get_qr(qr_HARDCODED_LITEM_LTMS))
2463 {
2464
2/2
✓ Branch 0 taken 1095230 times.
✓ Branch 1 taken 54980546 times.
56075776 switch(i)
2465 {
2466 case itype_bomb:
2467 case itype_sbomb:
2468 case itype_clock:
2469 case itype_key:
2470 case itype_lkey:
2471 case itype_map:
2472 case itype_compass:
2473 case itype_bosskey:
2474 case itype_magiccontainer:
2475 case itype_triforcepiece:
2476 1095230 continue; //already handled
2477 }
2478 54980546 }
2479 3097432002 int32_t itemid = current_item_id(i,false);
2480
2/2
✓ Branch 0 taken 3091380191 times.
✓ Branch 1 taken 6051811 times.
3097432002 if(i == itype_shield)
2481 6051811 itemid = getCurrentShield(false);
2482
2483
4/4
✓ Branch 0 taken 80852133 times.
✓ Branch 1 taken 3016579869 times.
✓ Branch 2 taken 100981 times.
✓ Branch 3 taken 80751152 times.
3097432002 if(itemid < 0 || !checkbunny(itemid))
2484 3016680850 continue;
2485
2486 80751152 itemdata const& itm = itemsbuf[itemid];
2487
2488
2/2
✓ Branch 0 taken 75336675 times.
✓ Branch 1 taken 5414477 times.
80751152 switch(itm.family)
2489 {
2490 case itype_shield:
2491
1/2
✓ Branch 0 taken 5414477 times.
✗ Branch 1 not taken.
5414477 if(itm.flags & ITEM_FLAG9) //active shield
2492 {
2493 if(!usingActiveShield(itemid))
2494 {
2495 tile+=itm.misc6; //'Inactive PTM'
2496 continue;
2497 }
2498 }
2499 5414477 break;
2500 }
2501
2502 80751152 tile+=itm.ltm;
2503 80751152 }
2504
2505 6051811 return tile;
2506 }
2507
2508 6051811 int32_t bunny_tile_mod()
2509 {
2510
2/2
✓ Branch 0 taken 1870 times.
✓ Branch 1 taken 6049941 times.
6051811 if(Hero.BunnyClock())
2511 {
2512 1870 return game->get_bunny_ltm();
2513 }
2514 6049941 return 0;
2515 6051811 }
2516
2517 // Hints are drawn on a separate layer to combo reveals.
2518 16332 void draw_lens_under(BITMAP *dest, bool layer)
2519 {
2520 //Lens flag 1: Replacement for qr_LENSHINTS; if set, lens will show hints. Does nothing if flag 2 is set.
2521 //Lens flag 2: Disable "hints", prevent rendering of Secret Combos
2522 //Lens flag 3: Don't show armos/chest/dive items
2523 //Lens flag 4: Show Raft Paths
2524 //Lens flag 5: Show Invisible Enemies
2525
4/4
✓ Branch 0 taken 456 times.
✓ Branch 1 taken 15876 times.
✓ Branch 2 taken 7938 times.
✓ Branch 3 taken 7938 times.
16332 bool hints = (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2) ? false : (layer && (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG1));
2526
2527 16332 int32_t strike_hint_table[11]=
2528 {
2529 mfARROW, mfBOMB, mfBRANG, mfWANDMAGIC,
2530 mfSWORD, mfREFMAGIC, mfHOOKSHOT,
2531 mfREFFIREBALL, mfHAMMER, mfSWORDBEAM, mfWAND
2532 };
2533
2534 // int32_t page = tmpscr->cpage;
2535 {
2536 16332 int32_t blink_rate=flash_reduction_enabled()?6:1;
2537 // int32_t temptimer=0;
2538 16332 int32_t tempitem, tempweapon=0;
2539 16332 strike_hint=strike_hint_table[strike_hint_counter];
2540
2541
2/2
✓ Branch 0 taken 15842 times.
✓ Branch 1 taken 490 times.
16332 if(strike_hint_timer>32)
2542 {
2543 490 strike_hint_timer=0;
2544 490 strike_hint_counter=((strike_hint_counter+1)%11);
2545 490 }
2546
2547 16332 ++strike_hint_timer;
2548
2549
2/2
✓ Branch 0 taken 2874432 times.
✓ Branch 1 taken 16332 times.
2890764 for(int32_t i=0; i<176; i++)
2550 {
2551 2874432 int32_t x = (i & 15) << 4;
2552 2874432 int32_t y = (i & 0xF0) + playing_field_offset;
2553 2874432 int32_t tempitemx=-16, tempitemy=-16;
2554 2874432 int32_t tempweaponx=-16, tempweapony=-16;
2555
2556
2/2
✓ Branch 0 taken 5748864 times.
✓ Branch 1 taken 2874432 times.
8623296 for(int32_t iter=0; iter<2; ++iter)
2557 {
2558 5748864 int32_t checkflag=0;
2559
2560
2/2
✓ Branch 0 taken 2874432 times.
✓ Branch 1 taken 2874432 times.
5748864 if(iter==0)
2561 {
2562 2874432 checkflag=combobuf[tmpscr->data[i]].flag;
2563 2874432 }
2564 else
2565 {
2566 2874432 checkflag=tmpscr->sflag[i];
2567 }
2568
2569
2/2
✓ Branch 0 taken 5747766 times.
✓ Branch 1 taken 1098 times.
5748864 if(checkflag==mfSTRIKE)
2570 {
2571
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 906 times.
1098 if(!hints)
2572 {
2573
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTRIKE],tmpscr->secretcset[sSTRIKE]);
2574 906 }
2575 else
2576 {
2577 192 checkflag = strike_hint;
2578 }
2579 1098 }
2580
2581
20/36
✓ Branch 0 taken 5706470 times.
✓ Branch 1 taken 3148 times.
✓ Branch 2 taken 3618 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2064 times.
✓ Branch 5 taken 28640 times.
✓ Branch 6 taken 2418 times.
✓ Branch 7 taken 504 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 814 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 33 times.
✓ Branch 15 taken 96 times.
✓ Branch 16 taken 24 times.
✓ Branch 17 taken 5 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 16 times.
✓ Branch 22 taken 16 times.
✓ Branch 23 taken 7 times.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 16 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 17 times.
✓ Branch 32 taken 35 times.
✓ Branch 33 taken 17 times.
✗ Branch 34 not taken.
✓ Branch 35 taken 906 times.
5748864 switch(checkflag)
2582 {
2583 case 0:
2584 case mfZELDA:
2585 case mfPUSHED:
2586 case mfENEMY0:
2587 case mfENEMY1:
2588 case mfENEMY2:
2589 case mfENEMY3:
2590 case mfENEMY4:
2591 case mfENEMY5:
2592 case mfENEMY6:
2593 case mfENEMY7:
2594 case mfENEMY8:
2595 case mfENEMY9:
2596 case mfSINGLE:
2597 case mfSINGLE16:
2598 case mfNOENEMY:
2599 case mfTRAP_H:
2600 case mfTRAP_V:
2601 case mfTRAP_4:
2602 case mfTRAP_LR:
2603 case mfTRAP_UD:
2604 case mfNOGROUNDENEMY:
2605 case mfNOBLOCKS:
2606 case mfSCRIPT1:
2607 case mfSCRIPT2:
2608 case mfSCRIPT3:
2609 case mfSCRIPT4:
2610 case mfSCRIPT5:
2611 case mfSCRIPT6:
2612 case mfSCRIPT7:
2613 case mfSCRIPT8:
2614 case mfSCRIPT9:
2615 case mfSCRIPT10:
2616 case mfSCRIPT11:
2617 case mfSCRIPT12:
2618 case mfSCRIPT13:
2619 case mfSCRIPT14:
2620 case mfSCRIPT15:
2621 case mfSCRIPT16:
2622 case mfSCRIPT17:
2623 case mfSCRIPT18:
2624 case mfSCRIPT19:
2625 case mfSCRIPT20:
2626 case mfPITHOLE:
2627 case mfPITFALLFLOOR:
2628 case mfLAVA:
2629 case mfICE:
2630 case mfICEDAMAGE:
2631 case mfDAMAGE1:
2632 case mfDAMAGE2:
2633 case mfDAMAGE4:
2634 case mfDAMAGE8:
2635 case mfDAMAGE16:
2636 case mfDAMAGE32:
2637 case mfFREEZEALL:
2638 case mfFREZEALLANSFFCS:
2639 case mfFREEZEFFCSOLY:
2640 case mfSCRITPTW1TRIG:
2641 case mfSCRITPTW2TRIG:
2642 case mfSCRITPTW3TRIG:
2643 case mfSCRITPTW4TRIG:
2644 case mfSCRITPTW5TRIG:
2645 case mfSCRITPTW6TRIG:
2646 case mfSCRITPTW7TRIG:
2647 case mfSCRITPTW8TRIG:
2648 case mfSCRITPTW9TRIG:
2649 case mfSCRITPTW10TRIG:
2650 case mfTROWEL:
2651 case mfTROWELNEXT:
2652 case mfTROWELSPECIALITEM:
2653 case mfSLASHPOT:
2654 case mfLIFTPOT:
2655 case mfLIFTORSLASH:
2656 case mfLIFTROCK:
2657 case mfLIFTROCKHEAVY:
2658 case mfDROPITEM:
2659 case mfSPECIALITEM:
2660 case mfDROPKEY:
2661 case mfDROPLKEY:
2662 case mfDROPCOMPASS:
2663 case mfDROPMAP:
2664 case mfDROPBOSSKEY:
2665 case mfSPAWNNPC:
2666 case mfSWITCHHOOK:
2667 case mfSIDEVIEWLADDER:
2668 case mfSIDEVIEWPLATFORM:
2669 case mfNOENEMYSPAWN:
2670 case mfENEMYALL:
2671 case mfNOMIRROR:
2672 case mfUNSAFEGROUND:
2673 case mf168:
2674 case mf169:
2675 case mf170:
2676 case mf171:
2677 case mf172:
2678 case mf173:
2679 case mf174:
2680 case mf175:
2681 case mf176:
2682 case mf177:
2683 case mf178:
2684 case mf179:
2685 case mf180:
2686 case mf181:
2687 case mf182:
2688 case mf183:
2689 case mf184:
2690 case mf185:
2691 case mf186:
2692 case mf187:
2693 case mf188:
2694 case mf189:
2695 case mf190:
2696 case mf191:
2697 case mf192:
2698 case mf193:
2699 case mf194:
2700 case mf195:
2701 case mf196:
2702 case mf197:
2703 case mf198:
2704 case mf199:
2705 case mf200:
2706 case mf201:
2707 case mf202:
2708 case mf203:
2709 case mf204:
2710 case mf205:
2711 case mf206:
2712 case mf207:
2713 case mf208:
2714 case mf209:
2715 case mf210:
2716 case mf211:
2717 case mf212:
2718 case mf213:
2719 case mf214:
2720 case mf215:
2721 case mf216:
2722 case mf217:
2723 case mf218:
2724 case mf219:
2725 case mf220:
2726 case mf221:
2727 case mf222:
2728 case mf223:
2729 case mf224:
2730 case mf225:
2731 case mf226:
2732 case mf227:
2733 case mf228:
2734 case mf229:
2735 case mf230:
2736 case mf231:
2737 case mf232:
2738 case mf233:
2739 case mf234:
2740 case mf235:
2741 case mf236:
2742 case mf237:
2743 case mf238:
2744 case mf239:
2745 case mf240:
2746 case mf241:
2747 case mf242:
2748 case mf243:
2749 case mf244:
2750 case mf245:
2751 case mf246:
2752 case mf247:
2753 case mf248:
2754 case mf249:
2755 case mf250:
2756 case mf251:
2757 case mf252:
2758 case mf253:
2759 case mf254:
2760 case mfEXTENDED:
2761 5706470 break;
2762
2763 case mfPUSHUD:
2764 case mfPUSHLR:
2765 case mfPUSH4:
2766 case mfPUSHU:
2767 case mfPUSHD:
2768 case mfPUSHL:
2769 case mfPUSHR:
2770 case mfPUSHUDNS:
2771 case mfPUSHLRNS:
2772 case mfPUSH4NS:
2773 case mfPUSHUNS:
2774 case mfPUSHDNS:
2775 case mfPUSHLNS:
2776 case mfPUSHRNS:
2777 case mfPUSHUDINS:
2778 case mfPUSHLRINS:
2779 case mfPUSH4INS:
2780 case mfPUSHUINS:
2781 case mfPUSHDINS:
2782 case mfPUSHLINS:
2783 case mfPUSHRINS:
2784
3/4
✓ Branch 0 taken 1829 times.
✓ Branch 1 taken 1319 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1829 times.
3148 if(!hints && ((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&16))
2785
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1829 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1829 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1829 || ((get_debug() && zc_getkey(KEY_N)) && (frame&16))))
2786 {
2787 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->undercombo,tmpscr->undercset);
2788 }
2789
2790
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3148 times.
3148 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2791
3/6
✓ Branch 0 taken 2438 times.
✓ Branch 1 taken 710 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 710 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3148 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2792 {
2793
2/2
✓ Branch 0 taken 1406 times.
✓ Branch 1 taken 1032 times.
2438 if(hints)
2794 {
2795
3/3
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 897 times.
1032 switch(combobuf[tmpscr->data[i]].type)
2796 {
2797 case cPUSH_HEAVY:
2798 case cPUSH_HW:
2799 72 tempitem=getItemIDPower(itemsbuf,itype_bracelet,1);
2800 72 tempitemx=x, tempitemy=y;
2801
2802
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
72 if(tempitem>-1)
2803 72 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2804
2805 72 break;
2806
2807 case cPUSH_HEAVY2:
2808 case cPUSH_HW2:
2809 63 tempitem=getItemIDPower(itemsbuf,itype_bracelet,2);
2810 63 tempitemx=x, tempitemy=y;
2811
2812
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(tempitem>-1)
2813 63 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2814
2815 63 break;
2816 }
2817 1032 }
2818 2438 }
2819
2820 3148 break;
2821
2822 case mfWHISTLE:
2823
1/2
✓ Branch 0 taken 2418 times.
✗ Branch 1 not taken.
2418 if(hints)
2824 {
2825 tempitem=getItemID(itemsbuf,itype_whistle,1);
2826
2827 if(tempitem<0) break;
2828
2829 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2830 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2831 {
2832 tempitemx=x;
2833 tempitemy=y;
2834 }
2835
2836 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2837 }
2838
2839 2418 break;
2840
2841 //Why is this here?
2842 case mfFAIRY:
2843 case mfMAGICFAIRY:
2844 case mfALLFAIRY:
2845 if(hints)
2846 {
2847 tempitem=getItemID(itemsbuf, itype_fairy,1);//iFairyMoving;
2848
2849 if(tempitem < 0) break;
2850
2851 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2852 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2853 {
2854 tempitemx=x;
2855 tempitemy=y;
2856 }
2857
2858 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2859 }
2860
2861 break;
2862
2863 case mfANYFIRE:
2864
2/2
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 252 times.
504 if(!hints)
2865 {
2866
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBCANDLE],tmpscr->secretcset[sBCANDLE]);
2867 252 }
2868 else
2869 {
2870 252 tempitem=getItemID(itemsbuf,itype_candle,1);
2871
2872
1/2
✓ Branch 0 taken 252 times.
✗ Branch 1 not taken.
252 if(tempitem<0) break;
2873
2874
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2875
3/6
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 63 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 63 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
252 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2876 {
2877 189 tempitemx=x;
2878 189 tempitemy=y;
2879 189 }
2880
2881 252 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2882 }
2883
2884 504 break;
2885
2886 case mfSTRONGFIRE:
2887 if(!hints)
2888 {
2889 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sRCANDLE],tmpscr->secretcset[sRCANDLE]);
2890 }
2891 else
2892 {
2893 tempitem=getItemID(itemsbuf,itype_candle,2);
2894
2895 if(tempitem<0) break;
2896
2897 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2898 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2899 {
2900 tempitemx=x;
2901 tempitemy=y;
2902 }
2903
2904 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2905 }
2906
2907 break;
2908
2909 case mfMAGICFIRE:
2910 if(!hints)
2911 {
2912 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDFIRE],tmpscr->secretcset[sWANDFIRE]);
2913 }
2914 else
2915 {
2916 tempitem=getItemID(itemsbuf,itype_wand,1);
2917
2918 if(tempitem<0) break;
2919
2920 tempweapon=wFire;
2921
2922 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2923 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2924 {
2925 tempitemx=x;
2926 tempitemy=y;
2927 }
2928 else
2929 {
2930 tempweaponx=x;
2931 tempweapony=y;
2932 }
2933
2934 putweapon(dest,tempweaponx,tempweapony,tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
2935 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2936 }
2937
2938 break;
2939
2940 case mfDIVINEFIRE:
2941 if(!hints)
2942 {
2943 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sDIVINEFIRE],tmpscr->secretcset[sDIVINEFIRE]);
2944 }
2945 else
2946 {
2947 tempitem=getItemID(itemsbuf,itype_divinefire,1);
2948
2949 if(tempitem<0) break;
2950
2951 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2952 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2953 {
2954 tempitemx=x;
2955 tempitemy=y;
2956 }
2957
2958 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2959 }
2960
2961 break;
2962
2963 case mfARROW:
2964
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 732 times.
814 if(!hints)
2965 {
2966
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 732 times.
732 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sARROW],tmpscr->secretcset[sARROW]);
2967 732 }
2968 else
2969 {
2970 82 tempitem=getItemID(itemsbuf,itype_arrow,1);
2971
2972
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if(tempitem<0) break;
2973
2974
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2975
3/6
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
82 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2976 {
2977 61 tempitemx=x;
2978 61 tempitemy=y;
2979 61 }
2980
2981 82 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2982 }
2983
2984 814 break;
2985
2986 case mfSARROW:
2987 if(!hints)
2988 {
2989 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSARROW],tmpscr->secretcset[sSARROW]);
2990 }
2991 else
2992 {
2993 tempitem=getItemID(itemsbuf,itype_arrow,2);
2994
2995 if(tempitem<0) break;
2996
2997 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2998 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2999 {
3000 tempitemx=x;
3001 tempitemy=y;
3002 }
3003
3004 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3005 }
3006
3007 break;
3008
3009 case mfGARROW:
3010 if(!hints)
3011 {
3012 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sGARROW],tmpscr->secretcset[sGARROW]);
3013 }
3014 else
3015 {
3016 tempitem=getItemID(itemsbuf,itype_arrow,3);
3017
3018 if(tempitem<0) break;
3019
3020 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3021 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3022 {
3023 tempitemx=x;
3024 tempitemy=y;
3025 }
3026
3027 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3028 }
3029
3030 break;
3031
3032 case mfBOMB:
3033
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 16 times.
33 if(!hints)
3034 {
3035
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBOMB],tmpscr->secretcset[sBOMB]);
3036 16 }
3037 else
3038 {
3039 //tempitem=getItemID(itemsbuf,itype_bomb,1);
3040 17 tempweapon = wLitBomb;
3041
3042 //if (tempitem<0) break;
3043
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3044
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3045 {
3046 12 tempweaponx=x;
3047 12 tempweapony=y;
3048 12 }
3049
3050 17 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3051 }
3052
3053 33 break;
3054
3055 case mfSBOMB:
3056
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 48 times.
96 if(!hints)
3057 {
3058
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSBOMB],tmpscr->secretcset[sSBOMB]);
3059 48 }
3060 else
3061 {
3062 //tempitem=getItemID(itemsbuf,itype_sbomb,1);
3063 //if (tempitem<0) break;
3064 48 tempweapon = wLitSBomb;
3065
3066
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3067
3/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3068 {
3069 36 tempweaponx=x;
3070 36 tempweapony=y;
3071 36 }
3072
3073 48 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3074 }
3075
3076 96 break;
3077
3078 case mfARMOS_SECRET:
3079
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 12 times.
24 if(!hints)
3080 {
3081
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3082 12 }
3083 24 break;
3084
3085 case mfBRANG:
3086
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(!hints)
3087 {
3088 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBRANG],tmpscr->secretcset[sBRANG]);
3089 }
3090 else
3091 {
3092 5 tempitem=getItemID(itemsbuf,itype_brang,1);
3093
3094
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(tempitem<0) break;
3095
3096
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3097
3/6
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3098 {
3099 4 tempitemx=x;
3100 4 tempitemy=y;
3101 4 }
3102
3103 5 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3104 }
3105
3106 5 break;
3107
3108 case mfMBRANG:
3109 if(!hints)
3110 {
3111 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMBRANG],tmpscr->secretcset[sMBRANG]);
3112 }
3113 else
3114 {
3115 tempitem=getItemID(itemsbuf,itype_brang,2);
3116
3117 if(tempitem<0) break;
3118
3119 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3120 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3121 {
3122 tempitemx=x;
3123 tempitemy=y;
3124 }
3125
3126 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3127 }
3128
3129 break;
3130
3131 case mfFBRANG:
3132 if(!hints)
3133 {
3134 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sFBRANG],tmpscr->secretcset[sFBRANG]);
3135 }
3136 else
3137 {
3138 tempitem=getItemID(itemsbuf,itype_brang,3);
3139
3140 if(tempitem<0) break;
3141
3142 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3143 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3144 {
3145 tempitemx=x;
3146 tempitemy=y;
3147 }
3148
3149 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3150 }
3151
3152 break;
3153
3154 case mfWANDMAGIC:
3155 if(!hints)
3156 {
3157 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDMAGIC],tmpscr->secretcset[sWANDMAGIC]);
3158 }
3159 else
3160 {
3161 tempitem=getItemID(itemsbuf,itype_wand,1);
3162
3163 if(tempitem<0) break;
3164
3165 tempweapon=itemsbuf[tempitem].wpn3;
3166
3167 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3168 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3169 {
3170 tempitemx=x;
3171 tempitemy=y;
3172 }
3173 else
3174 {
3175 tempweaponx=x;
3176 tempweapony=y;
3177 --lens_hint_weapon[wMagic][4];
3178
3179 if(lens_hint_weapon[wMagic][4]<-8)
3180 {
3181 lens_hint_weapon[wMagic][4]=8;
3182 }
3183 }
3184
3185 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3186 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3187 }
3188
3189 break;
3190
3191 case mfREFMAGIC:
3192
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3193 {
3194 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFMAGIC],tmpscr->secretcset[sREFMAGIC]);
3195 }
3196 else
3197 {
3198 16 tempitem=getItemID(itemsbuf,itype_shield,3);
3199
3200
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3201
3202 16 tempweapon=ewMagic;
3203
3204
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3205
3/6
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3206 {
3207 13 tempitemx=x;
3208 13 tempitemy=y;
3209 13 }
3210 else
3211 {
3212 3 tempweaponx=x;
3213 3 tempweapony=y;
3214
3215
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
3 if(lens_hint_weapon[ewMagic][2]==up)
3216 {
3217 1 --lens_hint_weapon[ewMagic][4];
3218 1 }
3219 else
3220 {
3221 2 ++lens_hint_weapon[ewMagic][4];
3222 }
3223
3224
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(lens_hint_weapon[ewMagic][4]>8)
3225 {
3226 lens_hint_weapon[ewMagic][2]=up;
3227 }
3228
3229
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
3 if(lens_hint_weapon[ewMagic][4]<=0)
3230 {
3231 2 lens_hint_weapon[ewMagic][2]=down;
3232 2 }
3233 }
3234
3235 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3236 16 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, lens_hint_weapon[ewMagic][2], lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3237 }
3238
3239 16 break;
3240
3241 case mfREFFIREBALL:
3242
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3243 {
3244 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFFIREBALL],tmpscr->secretcset[sREFFIREBALL]);
3245 }
3246 else
3247 {
3248 16 tempitem=getItemID(itemsbuf,itype_shield,3);
3249
3250
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3251
3252 16 tempweapon=ewFireball;
3253
3254
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3255
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3256 {
3257 12 tempitemx=x;
3258 12 tempitemy=y;
3259 12 tempweaponx=x;
3260 12 tempweapony=y;
3261 12 ++lens_hint_weapon[ewFireball][3];
3262
3263
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 1 times.
12 if(lens_hint_weapon[ewFireball][3]>8)
3264 {
3265 1 lens_hint_weapon[ewFireball][3]=-8;
3266 1 lens_hint_weapon[ewFireball][4]=8;
3267 1 }
3268
3269
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 4 times.
12 if(lens_hint_weapon[ewFireball][3]>0)
3270 {
3271 8 ++lens_hint_weapon[ewFireball][4];
3272 8 }
3273 else
3274 {
3275 4 --lens_hint_weapon[ewFireball][4];
3276 }
3277 12 }
3278
3279 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3280 16 putweapon(dest,tempweaponx+lens_hint_weapon[tempweapon][3],tempweapony+lens_hint_weapon[ewFireball][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3281 }
3282
3283 16 break;
3284
3285 case mfSWORD:
3286
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(!hints)
3287 {
3288 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORD],tmpscr->secretcset[sSWORD]);
3289 }
3290 else
3291 {
3292 7 tempitem=getItemID(itemsbuf,itype_sword,1);
3293
3294
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(tempitem<0) break;
3295
3296
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3297
3/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3298 {
3299 5 tempitemx=x;
3300 5 tempitemy=y;
3301 5 }
3302
3303 7 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3304 }
3305
3306 7 break;
3307
3308 case mfWSWORD:
3309 if(!hints)
3310 {
3311 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORD],tmpscr->secretcset[sWSWORD]);
3312 }
3313 else
3314 {
3315 tempitem=getItemID(itemsbuf,itype_sword,2);
3316
3317 if(tempitem<0) break;
3318
3319 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3320 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3321 {
3322 tempitemx=x;
3323 tempitemy=y;
3324 }
3325
3326 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3327 }
3328
3329 break;
3330
3331 case mfMSWORD:
3332 if(!hints)
3333 {
3334 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORD],tmpscr->secretcset[sMSWORD]);
3335 }
3336 else
3337 {
3338 tempitem=getItemID(itemsbuf,itype_sword,3);
3339
3340 if(tempitem<0) break;
3341
3342 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3343 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3344 {
3345 tempitemx=x;
3346 tempitemy=y;
3347 }
3348
3349 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3350 }
3351
3352 break;
3353
3354 case mfXSWORD:
3355 if(!hints)
3356 {
3357 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORD],tmpscr->secretcset[sXSWORD]);
3358 }
3359 else
3360 {
3361 tempitem=getItemID(itemsbuf,itype_sword,4);
3362
3363 if(tempitem<0) break;
3364
3365 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3366 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3367 {
3368 tempitemx=x;
3369 tempitemy=y;
3370 }
3371
3372 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3373 }
3374
3375 break;
3376
3377 case mfSWORDBEAM:
3378
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3379 {
3380 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORDBEAM],tmpscr->secretcset[sSWORDBEAM]);
3381 }
3382 else
3383 {
3384 16 tempitem=getItemID(itemsbuf,itype_sword,1);
3385
3386
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3387
3388
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3389
3/6
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3390 {
3391 11 tempitemx=x;
3392 11 tempitemy=y;
3393 11 }
3394
3395 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 1);
3396 }
3397
3398 16 break;
3399
3400 case mfWSWORDBEAM:
3401 if(!hints)
3402 {
3403 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORDBEAM],tmpscr->secretcset[sWSWORDBEAM]);
3404 }
3405 else
3406 {
3407 tempitem=getItemID(itemsbuf,itype_sword,2);
3408
3409 if(tempitem<0) break;
3410
3411 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3412 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3413 {
3414 tempitemx=x;
3415 tempitemy=y;
3416 }
3417
3418 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 2);
3419 }
3420
3421 break;
3422
3423 case mfMSWORDBEAM:
3424 if(!hints)
3425 {
3426 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORDBEAM],tmpscr->secretcset[sMSWORDBEAM]);
3427 }
3428 else
3429 {
3430 tempitem=getItemID(itemsbuf,itype_sword,3);
3431
3432 if(tempitem<0) break;
3433
3434 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3435 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3436 {
3437 tempitemx=x;
3438 tempitemy=y;
3439 }
3440
3441 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 3);
3442 }
3443
3444 break;
3445
3446 case mfXSWORDBEAM:
3447 if(!hints)
3448 {
3449 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORDBEAM],tmpscr->secretcset[sXSWORDBEAM]);
3450 }
3451 else
3452 {
3453 tempitem=getItemID(itemsbuf,itype_sword,4);
3454
3455 if(tempitem<0) break;
3456
3457 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3458 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3459 {
3460 tempitemx=x;
3461 tempitemy=y;
3462 }
3463
3464 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 4);
3465 }
3466
3467 break;
3468
3469 case mfHOOKSHOT:
3470
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
3471 {
3472 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHOOKSHOT],tmpscr->secretcset[sHOOKSHOT]);
3473 }
3474 else
3475 {
3476 17 tempitem=getItemID(itemsbuf,itype_hookshot,1);
3477
3478
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tempitem<0) break;
3479
3480
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3481
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3482 {
3483 12 tempitemx=x;
3484 12 tempitemy=y;
3485 12 }
3486
3487 17 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3488 }
3489
3490 17 break;
3491
3492 case mfWAND:
3493
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!hints)
3494 {
3495 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWAND],tmpscr->secretcset[sWAND]);
3496 }
3497 else
3498 {
3499 35 tempitem=getItemID(itemsbuf,itype_wand,1);
3500
3501
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(tempitem<0) break;
3502
3503
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3504
3/6
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
35 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3505 {
3506 28 tempitemx=x;
3507 28 tempitemy=y;
3508 28 }
3509
3510 35 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3511 }
3512
3513 35 break;
3514
3515 case mfHAMMER:
3516
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
3517 {
3518 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHAMMER],tmpscr->secretcset[sHAMMER]);
3519 }
3520 else
3521 {
3522 17 tempitem=getItemID(itemsbuf,itype_hammer,1);
3523
3524
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tempitem<0) break;
3525
3526
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3527
3/6
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3528 {
3529 13 tempitemx=x;
3530 13 tempitemy=y;
3531 13 }
3532
3533 17 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3534 }
3535
3536 17 break;
3537
3538 case mfARMOS_ITEM:
3539 case mfDIVE_ITEM:
3540
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2064 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2064 times.
2064 if((!getmapflag() || (tmpscr->flags9&fBELOWRETURN)) && !(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG3))
3541 {
3542 2064 putitem2(dest,x,y,tmpscr->catchall, lens_hint_item[tmpscr->catchall][0], lens_hint_item[tmpscr->catchall][1], 0);
3543 2064 }
3544 2064 break;
3545
3546 case 16:
3547 case 17:
3548 case 18:
3549 case 19:
3550 case 20:
3551 case 21:
3552 case 22:
3553 case 23:
3554 case 24:
3555 case 25:
3556 case 26:
3557 case 27:
3558 case 28:
3559 case 29:
3560 case 30:
3561 case 31:
3562
2/2
✓ Branch 0 taken 1008 times.
✓ Branch 1 taken 2610 times.
3618 if(!hints)
3563
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2610 times.
5220 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3564 2610 putcombo(dest,x,y,tmpscr->secretcombo[checkflag-16+4],tmpscr->secretcset[checkflag-16+4]);
3565
3566 3618 break;
3567 case mfSECRETSNEXT:
3568 if(!hints)
3569 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3570 putcombo(dest,x,y,tmpscr->data[i]+1,tmpscr->cset[i]);
3571
3572 break;
3573
3574 case mfSTRIKE:
3575
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3576 {
3577 906 goto special;
3578 }
3579 else
3580 {
3581 break;
3582 }
3583
3584 28640 default: goto special;
3585
3586 special:
3587
8/8
✓ Branch 0 taken 14677 times.
✓ Branch 1 taken 14869 times.
✓ Branch 2 taken 473 times.
✓ Branch 3 taken 14204 times.
✓ Branch 4 taken 441 times.
✓ Branch 5 taken 32 times.
✓ Branch 6 taken 6108 times.
✓ Branch 7 taken 8128 times.
29546 if(layer && ((checkflag!=mfRAFT && checkflag!=mfRAFT_BRANCH&& checkflag!=mfRAFT_BOUNCE) ||(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG4)))
3588 {
3589
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6549 times.
✓ Branch 2 taken 4913 times.
✓ Branch 3 taken 1636 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1636 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6549 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate)) || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3590 {
3591 4913 rectfill(dest,x,y,x+15,y+15,WHITE);
3592 4913 }
3593 6549 }
3594
3595 29546 break;
3596 }
3597 5748864 }
3598 2874432 }
3599
3600
2/2
✓ Branch 0 taken 8166 times.
✓ Branch 1 taken 8166 times.
16332 if(layer)
3601 {
3602
2/2
✓ Branch 0 taken 7978 times.
✓ Branch 1 taken 188 times.
8166 if(tmpscr->door[0]==dWALK)
3603 188 rectfill(dest, 120, 16+playing_field_offset, 135, 31+playing_field_offset, WHITE);
3604
3605
2/2
✓ Branch 0 taken 7969 times.
✓ Branch 1 taken 197 times.
8166 if(tmpscr->door[1]==dWALK)
3606 197 rectfill(dest, 120, 144+playing_field_offset, 135, 159+playing_field_offset, WHITE);
3607
3608
2/2
✓ Branch 0 taken 8014 times.
✓ Branch 1 taken 152 times.
8166 if(tmpscr->door[2]==dWALK)
3609 152 rectfill(dest, 16, 80+playing_field_offset, 31, 95+playing_field_offset, WHITE);
3610
3611
2/2
✓ Branch 0 taken 7940 times.
✓ Branch 1 taken 226 times.
8166 if(tmpscr->door[3]==dWALK)
3612 226 rectfill(dest, 224, 80+playing_field_offset, 239, 95+playing_field_offset, WHITE);
3613
3614
2/2
✓ Branch 0 taken 8123 times.
✓ Branch 1 taken 43 times.
8166 if(tmpscr->door[0]==dBOMB)
3615 {
3616 43 showbombeddoor(dest, 0);
3617 43 }
3618
3619
2/2
✓ Branch 0 taken 8127 times.
✓ Branch 1 taken 39 times.
8166 if(tmpscr->door[1]==dBOMB)
3620 {
3621 39 showbombeddoor(dest, 1);
3622 39 }
3623
3624
1/2
✓ Branch 0 taken 8166 times.
✗ Branch 1 not taken.
8166 if(tmpscr->door[2]==dBOMB)
3625 {
3626 showbombeddoor(dest, 2);
3627 }
3628
3629
2/2
✓ Branch 0 taken 8129 times.
✓ Branch 1 taken 37 times.
8166 if(tmpscr->door[3]==dBOMB)
3630 {
3631 37 showbombeddoor(dest, 3);
3632 37 }
3633 8166 }
3634
3635
2/2
✓ Branch 0 taken 14298 times.
✓ Branch 1 taken 2034 times.
16332 if(tmpscr->stairx + tmpscr->stairy)
3636 {
3637
2/2
✓ Branch 0 taken 911 times.
✓ Branch 1 taken 1123 times.
2034 if(!hints)
3638 {
3639
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1123 times.
1123 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3640 1123 putcombo(dest,tmpscr->stairx,tmpscr->stairy+playing_field_offset,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3641 1123 }
3642 else
3643 {
3644
2/2
✓ Branch 0 taken 863 times.
✓ Branch 1 taken 48 times.
911 if(tmpscr->flags&fWHISTLE)
3645 {
3646 48 tempitem=getItemID(itemsbuf,itype_whistle,1);
3647 48 int32_t tempitemx=-16;
3648 48 int32_t tempitemy=-16;
3649
3650
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&(blink_rate/4)))
3651
3/6
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 || ((get_debug() && zc_getkey(KEY_N)) && (frame&(blink_rate/4))))
3652 {
3653 24 tempitemx=tmpscr->stairx;
3654 24 tempitemy=tmpscr->stairy+playing_field_offset;
3655 24 }
3656
3657 48 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3658 48 }
3659 }
3660 2034 }
3661 }
3662 16332 }
3663
3664 BITMAP *lens_scr_d; // The "d" is for "destructible"!
3665
3666 7997 void draw_lens_over()
3667 {
3668 // Oh, what the heck.
3669 static BITMAP *lens_scr = NULL;
3670 static int32_t last_width = -1;
3671 7997 int32_t width = itemsbuf[current_item_id(itype_lens,true)].misc1;
3672
3673 // Only redraw the circle if the size has changed
3674
2/2
✓ Branch 0 taken 7987 times.
✓ Branch 1 taken 10 times.
7997 if(width != last_width)
3675 {
3676
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if(lens_scr == NULL)
3677 {
3678 10 lens_scr = create_bitmap_ex(8,2*288,2*(240-playing_field_offset));
3679 10 }
3680
3681 10 clear_to_color(lens_scr, BLACK);
3682 10 circlefill(lens_scr, 288, 240-playing_field_offset, width, 0);
3683 10 circle(lens_scr, 288, 240-playing_field_offset, width+2, 0);
3684 10 circle(lens_scr, 288, 240-playing_field_offset, width+5, 0);
3685 10 last_width=width;
3686 10 }
3687
3688 7997 masked_blit(lens_scr, framebuf, 288-(HeroX()+8), 240-playing_field_offset-(HeroY()+8), 0, playing_field_offset, 256, 168);
3689 7997 do_primitives(framebuf, SPLAYER_LENS_OVER, tmpscr, 0, playing_field_offset);
3690 7997 }
3691
3692 //----------------------------------------------------------------
3693
3694 31111 void draw_wavy(BITMAP *source, BITMAP *target, int32_t amplitude, bool interpol)
3695 {
3696 //recreating a big bitmap every frame is highly sluggish.
3697
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 31108 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
31111 static BITMAP *wavebuf = create_bitmap_ex(8,288,240-original_playing_field_offset);
3698 31111 clear_to_color(wavebuf, BLACK);
3699 31111 blit(source,wavebuf,0,original_playing_field_offset,16,0,256,224-original_playing_field_offset);
3700
3701 int32_t ofs;
3702 // int32_t amplitude=8;
3703 // int32_t wavelength=4;
3704
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31111 times.
31111 amplitude = zc_min(2048,amplitude); // some arbitrary limit to prevent crashing
3705
3/6
✓ Branch 0 taken 31111 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 31111 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 31111 times.
31111 if(flash_reduction_enabled() && !get_qr(qr_WAVY_NO_EPILEPSY)) amplitude = zc_min(16,amplitude);
3706 31111 int32_t amp2=168;
3707
2/4
✓ Branch 0 taken 31111 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 31111 times.
31111 if(flash_reduction_enabled() && !get_qr(qr_WAVY_NO_EPILEPSY_2)) amp2*=2;
3708 31111 int32_t i=frame%amp2;
3709
3710
2/2
✓ Branch 0 taken 5226648 times.
✓ Branch 1 taken 31111 times.
5257759 for(int32_t j=0; j<168; j++)
3711 {
3712
3/4
✓ Branch 0 taken 2613324 times.
✓ Branch 1 taken 2613324 times.
✓ Branch 2 taken 2613324 times.
✗ Branch 3 not taken.
5226648 if(j&1 && interpol)
3713 {
3714 // Add 288*2048 to ensure it's never negative. It'll get modded out.
3715 ofs=288*2048+int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3716 }
3717 else
3718 {
3719 5226648 ofs=288*2048-int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3720 }
3721
3722
1/2
✓ Branch 0 taken 5226648 times.
✗ Branch 1 not taken.
5226648 if(ofs)
3723 {
3724
2/2
✓ Branch 0 taken 1338021888 times.
✓ Branch 1 taken 5226648 times.
1343248536 for(int32_t k=0; k<256; k++)
3725 {
3726 1338021888 target->line[j+original_playing_field_offset][k]=wavebuf->line[j][(k+ofs+16)%288];
3727 1338021888 }
3728 5226648 }
3729 5226648 }
3730 31111 }
3731
3732 4848 void draw_fuzzy(int32_t fuzz)
3733 // draws from right half of scrollbuf to framebuf
3734 {
3735 int32_t firstx, firsty, xstep, ystep, i, y, dx, dy;
3736 byte *start, *si, *di;
3737
3738
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4848 times.
4848 if(fuzz<1)
3739 fuzz = 1;
3740
3741 4848 xstep = 128%fuzz;
3742
3743
2/2
✓ Branch 0 taken 1010 times.
✓ Branch 1 taken 3838 times.
4848 if(xstep > 0)
3744 3838 xstep = fuzz-xstep;
3745
3746 4848 ystep = 112%fuzz;
3747
3748
2/2
✓ Branch 0 taken 1414 times.
✓ Branch 1 taken 3434 times.
4848 if(ystep > 0)
3749 3434 ystep = fuzz-ystep;
3750
3751 4848 firsty = 1;
3752
3753
2/2
✓ Branch 0 taken 4848 times.
✓ Branch 1 taken 174932 times.
179780 for(y=0; y<224;)
3754 {
3755 174932 start = &(scrollbuf->line[y][256]);
3756
3757
4/4
✓ Branch 0 taken 172508 times.
✓ Branch 1 taken 1088376 times.
✓ Branch 2 taken 1085952 times.
✓ Branch 3 taken 174932 times.
1260884 for(dy=0; dy<ystep && dy+y<224; dy++)
3758 {
3759 1085952 si = start;
3760 1085952 di = &(framebuf->line[y+dy][0]);
3761 1085952 i = xstep;
3762 1085952 firstx = 1;
3763
3764
2/2
✓ Branch 0 taken 278003712 times.
✓ Branch 1 taken 1085952 times.
279089664 for(dx=0; dx<256; dx++)
3765 {
3766 278003712 *(di++) = *si;
3767
3768
2/2
✓ Branch 0 taken 234248896 times.
✓ Branch 1 taken 43754816 times.
278003712 if(++i >= fuzz)
3769 {
3770
2/2
✓ Branch 0 taken 42668864 times.
✓ Branch 1 taken 1085952 times.
43754816 if(!firstx)
3771 42668864 si += fuzz;
3772 else
3773 {
3774 1085952 si += fuzz-xstep;
3775 1085952 firstx = 0;
3776 }
3777
3778 43754816 i = 0;
3779 43754816 }
3780 278003712 }
3781 1085952 }
3782
3783
2/2
✓ Branch 0 taken 170084 times.
✓ Branch 1 taken 4848 times.
174932 if(!firsty)
3784 170084 y += fuzz;
3785 else
3786 {
3787 4848 y += ystep;
3788 4848 ystep = fuzz;
3789 4848 firsty = 0;
3790 }
3791 }
3792 4848 }
3793
3794 9285079 void updatescr(bool allowwavy)
3795 {
3796
4/6
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 9284963 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 116 times.
✓ Branch 4 taken 116 times.
✗ Branch 5 not taken.
9285079 static BITMAP *wavybuf = create_bitmap_ex(8,256,224);
3797
4/6
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 9284963 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 116 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 116 times.
9285079 static BITMAP *panorama = create_bitmap_ex(8,256,224);
3798
3799
2/2
✓ Branch 0 taken 9258314 times.
✓ Branch 1 taken 26765 times.
9285079 if(toogam)
3800 {
3801 26765 textout_ex(framebuf,font,"no walls",8,216,1,-1);
3802 26765 }
3803
3804
1/2
✓ Branch 0 taken 9285079 times.
✗ Branch 1 not taken.
9285079 if(Showpal)
3805 dump_pal(framebuf);
3806
3807
2/2
✓ Branch 0 taken 8984016 times.
✓ Branch 1 taken 301063 times.
9285079 if(!Playing)
3808 301063 black_opening_count=0;
3809
3810
2/2
✓ Branch 0 taken 9211819 times.
✓ Branch 1 taken 73260 times.
9285079 if(black_opening_count<0) //shape is opening up
3811 {
3812 73260 black_opening(framebuf,black_opening_x,black_opening_y,(66+black_opening_count),66);
3813
3814
2/4
✓ Branch 0 taken 73260 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 73260 times.
73260 if(Advance||(!Paused))
3815 {
3816 73260 ++black_opening_count;
3817 73260 }
3818 73260 }
3819
2/2
✓ Branch 0 taken 9185683 times.
✓ Branch 1 taken 26136 times.
9211819 else if(black_opening_count>0) //shape is closing
3820 {
3821 26136 black_opening(framebuf,black_opening_x,black_opening_y,black_opening_count,66);
3822
3823
2/4
✓ Branch 0 taken 26136 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 26136 times.
26136 if(Advance||(!Paused))
3824 {
3825 26136 --black_opening_count;
3826 26136 }
3827 26136 }
3828
3829
3/4
✓ Branch 0 taken 9187189 times.
✓ Branch 1 taken 97890 times.
✓ Branch 2 taken 9187189 times.
✗ Branch 3 not taken.
9285079 if(black_opening_count==0&&black_opening_shape==bosFADEBLACK)
3830 {
3831 black_opening_shape = bosCIRCLE;
3832 memcpy(RAMpal, tempblackpal, PAL_SIZE*sizeof(RGB));
3833 refreshTints();
3834 refreshpal=true;
3835 }
3836
3837
2/2
✓ Branch 0 taken 9030880 times.
✓ Branch 1 taken 254199 times.
9285079 if(refreshpal)
3838 {
3839 254199 refreshpal=false;
3840 254199 RAMpal[253] = _RGB(0,0,0);
3841 254199 RAMpal[254] = _RGB(63,63,63);
3842 254199 hw_palette = &RAMpal;
3843 254199 update_hw_pal = true;
3844
3845 254199 create_rgb_table(&rgb_table, RAMpal, NULL);
3846 254199 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
3847 254199 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
3848
3849
2/2
✓ Branch 0 taken 65074944 times.
✓ Branch 1 taken 254199 times.
65329143 for(int32_t q=0; q<PAL_SIZE; q++)
3850 {
3851 65074944 trans_table2.data[0][q] = q;
3852 65074944 trans_table2.data[q][q] = q;
3853 65074944 }
3854 254199 }
3855
3856 9285079 bool clearwavy = (wavy <= 0);
3857
3858
2/2
✓ Branch 0 taken 7655 times.
✓ Branch 1 taken 9277424 times.
9285079 if(wavy <= 0)
3859 {
3860 // So far one thing can alter wavy apart from scripts: Wavy DMaps.
3861 9277424 wavy = (DMaps[currdmap].flags&dmfWAVY ? 4 : 0);
3862 9277424 }
3863
3864 9285079 blit(framebuf, wavybuf, 0, 0, 0, 0, 256, 224);
3865
3866
6/6
✓ Branch 0 taken 31361 times.
✓ Branch 1 taken 9253718 times.
✓ Branch 2 taken 31239 times.
✓ Branch 3 taken 122 times.
✓ Branch 4 taken 128 times.
✓ Branch 5 taken 31111 times.
9285079 if(wavy && Playing && allowwavy)
3867 {
3868 31111 draw_wavy(framebuf, wavybuf, wavy,false);
3869 31111 }
3870
3871
2/2
✓ Branch 0 taken 9277424 times.
✓ Branch 1 taken 7655 times.
9285079 if(clearwavy)
3872 9277424 wavy = 0; // Wavy was set by a DMap flag. Clear it.
3873
2/4
✓ Branch 0 taken 7655 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7655 times.
7655 else if(Playing && !Paused)
3874 7655 wavy--; // Wavy was set by a script. Decrement it.
3875
3876
5/6
✓ Branch 0 taken 8984016 times.
✓ Branch 1 taken 301063 times.
✓ Branch 2 taken 259574 times.
✓ Branch 3 taken 8724442 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 259574 times.
9285079 if(Playing && msgpos && !screenscrolling)
3877 {
3878
1/2
✓ Branch 0 taken 259574 times.
✗ Branch 1 not taken.
259574 if(!(msg_bg_display_buf->clip))
3879 259574 blit_msgstr_bg(framebuf,0,0,0,playing_field_offset,256,168);
3880
1/2
✓ Branch 0 taken 259574 times.
✗ Branch 1 not taken.
259574 if(!(msg_portrait_display_buf->clip))
3881 259574 blit_msgstr_prt(framebuf,0,0,0,playing_field_offset,256,168);
3882
1/2
✓ Branch 0 taken 259574 times.
✗ Branch 1 not taken.
259574 if(!(msg_txt_display_buf->clip))
3883 259574 blit_msgstr_fg(framebuf,0,0,0,playing_field_offset,256,168);
3884 259574 }
3885
3886 /*
3887 if(!(msg_txt_display_buf->clip) && Playing && msgpos && !screenscrolling)
3888 {
3889 BITMAP* subBmp = 0;
3890 masked_blit(msg_txt_display_buf,subBmp,0,0,0,playing_field_offset,256,168);
3891 // masked_blit(msg_txt_display_buf,subBmp,0,playing_field_offset,256,168);
3892 draw_trans_sprite(framebuf, subBmp, 0, playing_field_offset);
3893 destroy_bitmap(subBmp);
3894 //void draw_sprite_ex(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t mode, int32_t flip);
3895 // masked_blit(msg_txt_display_buf,framebuf,0,0,0,playing_field_offset,256,168);
3896 //void masked_blit(BITMAP *source, BITMAP *dest, int32_t source_x, int32_t source_y, int32_t dest_x, int32_t dest_y, int32_t width, int32_t height);
3897 }
3898 */
3899
3900
2/2
✓ Branch 0 taken 9244022 times.
✓ Branch 1 taken 41057 times.
9285079 bool nosubscr = (tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET));
3901
3902
2/2
✓ Branch 0 taken 9248647 times.
✓ Branch 1 taken 36432 times.
9285079 if(nosubscr)
3903 {
3904 36432 rectfill(panorama,0,0,255,passive_subscreen_height/2,0);
3905 36432 rectfill(panorama,0,168+passive_subscreen_height/2,255,168+passive_subscreen_height-1,0);
3906 36432 blit(wavybuf,panorama,0,playing_field_offset,0,passive_subscreen_height/2,256,224-passive_subscreen_height);
3907 36432 }
3908
3909 //TODO: Optimize blit 'overcalls' -Gleeok
3910
2/2
✓ Branch 0 taken 36432 times.
✓ Branch 1 taken 9248647 times.
9285079 BITMAP *source = nosubscr ? panorama : wavybuf;
3911 9285079 blit(source,framebuf,0,0,0,0,256,224);
3912
3913 9285079 update_hw_screen();
3914 9285079 }
3915
3916 //----------------------------------------------------------------
3917
3918 static PALETTE syspal;
3919 int32_t onGUISnapshot()
3920 {
3921 char buf[200];
3922 int32_t num=0;
3923 bool realpal=(key[KEY_ZC_LCONTROL] || key[KEY_ZC_RCONTROL]);
3924 do
3925 {
3926 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3927 }
3928 while(num<99999 && exists(buf));
3929
3930 BITMAP *b = create_bitmap_ex(8,resx,resy);
3931
3932 if(b)
3933 {
3934 blit(screen,b,0,0,0,0,resx,resy);
3935 save_bitmap(buf,b,RAMpal);
3936 destroy_bitmap(b);
3937 }
3938
3939 return D_O_K;
3940 }
3941
3942 int32_t onNonGUISnapshot()
3943 {
3944 PALETTE temppal;
3945 get_palette(temppal);
3946 bool realpal=(zc_getkey(KEY_ZC_LCONTROL, true) || zc_getkey(KEY_ZC_RCONTROL, true));
3947
3948 char buf[200];
3949 int32_t num=0;
3950
3951 do
3952 {
3953 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3954 }
3955 while(num<99999 && exists(buf));
3956
3957 save_bitmap(buf,framebuf,realpal?temppal:RAMpal);
3958
3959 return D_O_K;
3960 }
3961
3962 int32_t onSnapshot()
3963 {
3964 if(zc_getkey(KEY_LSHIFT, true)||zc_getkey(KEY_RSHIFT, true))
3965 {
3966 onGUISnapshot();
3967 }
3968 else
3969 {
3970 onNonGUISnapshot();
3971 }
3972
3973 return D_O_K;
3974 }
3975
3976 int32_t onSaveMapPic()
3977 {
3978 int32_t mapres2 = 0;
3979 char buf[200];
3980 int32_t num=0;
3981 mapscr tmpscr_b[2];
3982 mapscr tmpscr_c[6];
3983 BITMAP* _screen_draw_buffer = NULL;
3984 _screen_draw_buffer = create_bitmap_ex(8,256,224);
3985 set_clip_state(_screen_draw_buffer,1);
3986
3987 for(int32_t i=0; i<6; ++i)
3988 {
3989 tmpscr_c[i] = tmpscr2[i];
3990 tmpscr2[i].zero_memory();
3991
3992 if(i>=2)
3993 {
3994 continue;
3995 }
3996
3997 tmpscr_b[i] = tmpscr[i];
3998 tmpscr[i].zero_memory();
3999 }
4000
4001 do
4002 {
4003 sprintf(buf, "%szc_screen%05d.png", get_snap_str(), ++num);
4004 }
4005 while(num<99999 && exists(buf));
4006
4007 BITMAP* mappic = NULL;
4008
4009
4010 bool done=false, redraw=true;
4011
4012 mappic = create_bitmap_ex(8,(256*16)>>mapres,(176*8)>>mapres);
4013
4014 if(!mappic)
4015 {
4016 enter_sys_pal();
4017 jwin_alert("View Map","Not enough memory.",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
4018 exit_sys_pal();
4019 return D_O_K;;
4020 }
4021
4022 // draw the map
4023 set_clip_rect(_screen_draw_buffer, 0, 0, _screen_draw_buffer->w, _screen_draw_buffer->h);
4024
4025 for(int32_t y=0; y<8; y++)
4026 {
4027 for(int32_t x=0; x<16; x++)
4028 {
4029 if(!displayOnMap(x, y))
4030 {
4031 rectfill(_screen_draw_buffer, 0, 0, 255, 223, WHITE);
4032 }
4033 else
4034 {
4035 int32_t s = (y<<4) + x;
4036 loadscr2(1,s,-1);
4037
4038 for(int32_t i=0; i<6; i++)
4039 {
4040 if(tmpscr[1].layermap[i]<=0)
4041 continue;
4042
4043 if((ZCMaps[tmpscr[1].layermap[i]-1].tileWidth==ZCMaps[currmap].tileWidth) &&
4044 (ZCMaps[tmpscr[1].layermap[i]-1].tileHeight==ZCMaps[currmap].tileHeight))
4045 {
4046 const int32_t _mapsSize = (ZCMaps[currmap].tileWidth)*(ZCMaps[currmap].tileHeight);
4047
4048 tmpscr2[i]=TheMaps[(tmpscr[1].layermap[i]-1)*MAPSCRS+tmpscr[1].layerscreen[i]];
4049 }
4050 }
4051
4052 if(XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4053
4054 if(XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4055
4056 if(lenscheck(tmpscr+1,0)) putscr(_screen_draw_buffer,256,0,tmpscr+1);
4057 do_layer(_screen_draw_buffer, 0, 1, tmpscr+1, -256, playing_field_offset, 2);
4058
4059 if(!XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4060
4061 putscrdoors(_screen_draw_buffer,256,0,tmpscr+1);
4062 if(get_qr(qr_PUSHBLOCK_SPRITE_LAYER))
4063 {
4064 do_layer(_screen_draw_buffer, -2, 0, tmpscr+1, -256, playing_field_offset, 2);
4065 if(get_qr(qr_PUSHBLOCK_LAYER_1_2))
4066 {
4067 do_layer(_screen_draw_buffer, -2, 1, tmpscr+1, -256, playing_field_offset, 2);
4068 do_layer(_screen_draw_buffer, -2, 2, tmpscr+1, -256, playing_field_offset, 2);
4069 }
4070 }
4071 do_layer(_screen_draw_buffer, -3, 0, tmpscr+1, -256, playing_field_offset, 2); // Freeform combos!
4072
4073 if(!XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4074
4075 do_layer(_screen_draw_buffer, 0, 4, tmpscr+1, -256, playing_field_offset, 2);
4076 do_layer(_screen_draw_buffer, -1, 0, tmpscr+1, -256, playing_field_offset, 2);
4077 if(get_qr(qr_OVERHEAD_COMBOS_L1_L2))
4078 {
4079 do_layer(_screen_draw_buffer, -1, 1, tmpscr+1, -256, playing_field_offset, 2);
4080 do_layer(_screen_draw_buffer, -1, 2, tmpscr+1, -256, playing_field_offset, 2);
4081 }
4082 do_layer(_screen_draw_buffer, 0, 5, tmpscr+1, -256, playing_field_offset, 2);
4083 do_layer(_screen_draw_buffer, 0, 6, tmpscr+1, -256, playing_field_offset, 2);
4084
4085 }
4086
4087 stretch_blit(_screen_draw_buffer, mappic, 256, 0, 256, 176, x<<(8-mapres), (y*176)>>mapres, 256>>mapres, 176>>mapres);
4088 }
4089 }
4090
4091 for(int32_t i=0; i<6; ++i)
4092 {
4093 tmpscr2[i]=tmpscr_c[i];
4094
4095 if(i>=2)
4096 {
4097 continue;
4098 }
4099
4100 tmpscr[i]=tmpscr_b[i];
4101 }
4102
4103 save_bitmap(buf,mappic,RAMpal);
4104 destroy_bitmap(mappic);
4105 destroy_bitmap(_screen_draw_buffer);
4106 return D_O_K;
4107 }
4108
4109 13 void f_Quit(int32_t type)
4110 {
4111
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
13 if(type==qQUIT && !Playing)
4112 return;
4113
4114 13 bool from_menu = is_sys_pal;
4115
4116
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(!from_menu)
4117 {
4118 13 music_pause();
4119 13 pause_all_sfx();
4120 13 sys_mouse();
4121 13 }
4122 13 enter_sys_pal();
4123 13 clear_keybuf();
4124
4125
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if (replay_version_check(0, 10))
4126 13 replay_poll();
4127
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if (replay_is_replaying())
4128 13 replay_peek_quit();
4129
4130
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if (!replay_is_replaying())
4131 switch(type)
4132 {
4133 case qQUIT:
4134 onQuit();
4135 break;
4136
4137 case qRESET:
4138 onReset();
4139 break;
4140
4141 case qEXIT:
4142 onExit();
4143 break;
4144 }
4145
4146
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(Quit)
4147 {
4148 13 kill_sfx();
4149 13 music_stop();
4150 13 exit_sys_pal();
4151 13 update_hw_screen();
4152 13 }
4153 else
4154 {
4155 exit_sys_pal();
4156 if(!from_menu)
4157 {
4158 music_resume();
4159 resume_all_sfx();
4160 }
4161 }
4162
4163
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(!from_menu)
4164 13 game_mouse();
4165 13 eat_buttons();
4166
4167 13 zc_readrawkey(KEY_ESC);
4168
4169 13 zc_readrawkey(KEY_ENTER);
4170 13 }
4171
4172 //----------------------------------------------------------------
4173
4174 int32_t onNoWalls()
4175 {
4176 cheats_enqueue(Cheat::Walls);
4177 return D_O_K;
4178 }
4179
4180 int32_t onIgnoreSideview()
4181 {
4182 cheats_enqueue(Cheat::IgnoreSideView);
4183 return D_O_K;
4184 }
4185
4186 9284954 int32_t input_idle(bool checkmouse)
4187 {
4188 static int32_t mx, my, mz, mb;
4189
4190
4/6
✓ Branch 0 taken 9284954 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2461268 times.
✓ Branch 3 taken 6823686 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2461268 times.
11746222 if(keypressed() || zc_key_pressed() ||
4191
4/8
✓ Branch 0 taken 2461268 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2461268 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2461268 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2461268 times.
✗ Branch 7 not taken.
2461268 (checkmouse && (mx != mouse_x || my != mouse_y || mz != mouse_z || mb != mouse_b)))
4192 {
4193 6823686 idle_count = 0;
4194
4195
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6823686 times.
6823686 if(active_count < MAX_ACTIVE)
4196 {
4197 6823686 ++active_count;
4198 6823686 }
4199 6823686 }
4200
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2461268 times.
2461268 else if(idle_count < MAX_IDLE)
4201 {
4202 2461268 ++idle_count;
4203 2461268 active_count = 0;
4204 2461268 }
4205
4206 9284954 mx = mouse_x;
4207 9284954 my = mouse_y;
4208 9284954 mz = mouse_z;
4209 9284954 mb = mouse_b;
4210
4211 9284954 return idle_count;
4212 }
4213
4214 int32_t onGoFast()
4215 {
4216 cheats_enqueue(Cheat::Fast);
4217 return D_O_K;
4218 }
4219
4220 int32_t onKillCheat()
4221 {
4222 cheats_enqueue(Cheat::Kill);
4223 return D_O_K;
4224 }
4225
4226 int32_t onSecretsCheat()
4227 {
4228 cheats_enqueue(Cheat::TrigSecrets);
4229 return D_O_K;
4230 }
4231 int32_t onSecretsCheatPerm()
4232 {
4233 cheats_enqueue(Cheat::TrigSecretsPerm);
4234 return D_O_K;
4235 }
4236
4237 int32_t onShowLayer0()
4238 {
4239 show_layer_0 = !show_layer_0;
4240 return D_O_K;
4241 }
4242 int32_t onShowLayer1()
4243 {
4244 show_layer_1 = !show_layer_1;
4245 return D_O_K;
4246 }
4247 int32_t onShowLayer2()
4248 {
4249 show_layer_2 = !show_layer_2;
4250 return D_O_K;
4251 }
4252 int32_t onShowLayer3()
4253 {
4254 show_layer_3 = !show_layer_3;
4255 return D_O_K;
4256 }
4257 int32_t onShowLayer4()
4258 {
4259 show_layer_4 = !show_layer_4;
4260 return D_O_K;
4261 }
4262 int32_t onShowLayer5()
4263 {
4264 show_layer_5 = !show_layer_5;
4265 return D_O_K;
4266 }
4267 int32_t onShowLayer6()
4268 {
4269 show_layer_6 = !show_layer_6;
4270 return D_O_K;
4271 }
4272 int32_t onShowLayerO()
4273 {
4274 show_layer_over=!show_layer_over;
4275 return D_O_K;
4276 }
4277 int32_t onShowLayerP()
4278 {
4279 show_layer_push=!show_layer_push;
4280 return D_O_K;
4281 }
4282 int32_t onShowLayerS()
4283 {
4284 show_sprites=!show_sprites;
4285 return D_O_K;
4286 }
4287 int32_t onShowLayerF()
4288 {
4289 show_ffcs=!show_ffcs;
4290 return D_O_K;
4291 }
4292 int32_t onShowLayerW()
4293 {
4294 show_walkflags=!show_walkflags;
4295 if(show_walkflags)
4296 show_effectflags = false;
4297 return D_O_K;
4298 }
4299 int32_t onShowLayerE()
4300 {
4301 show_effectflags=!show_effectflags;
4302 if(show_effectflags)
4303 show_walkflags = false;
4304 return D_O_K;
4305 }
4306 int32_t onShowFFScripts()
4307 {
4308 show_ff_scripts=!show_ff_scripts;
4309 return D_O_K;
4310 }
4311 int32_t onShowHitboxes()
4312 {
4313 show_hitboxes=!show_hitboxes;
4314 return D_O_K;
4315 }
4316 int32_t onShowInfoOpacity()
4317 {
4318 info_opacity = vbound(getnumber("Debug Info Opacity",info_opacity),0,255);
4319 zc_set_config("zc","debug_info_opacity",info_opacity);
4320 return D_O_K;
4321 }
4322
4323 int32_t onLightSwitch()
4324 {
4325 cheats_enqueue(Cheat::Light);
4326 return D_O_K;
4327 }
4328
4329 int32_t onGoTo();
4330 int32_t onGoToComplete();
4331
4332 9284954 void syskeys()
4333 {
4334 9284954 update_system_keys();
4335
4336 int32_t oldtitle_version;
4337
4338
1/2
✓ Branch 0 taken 9284954 times.
✗ Branch 1 not taken.
9284954 if(close_button_quit)
4339 {
4340 close_button_quit=false;
4341 f_Quit(qEXIT);
4342 }
4343
4344 9284954 poll_joystick();
4345
4346
2/10
✓ Branch 0 taken 9284954 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 9284954 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
9284954 if(rMbtn() || (gui_mouse_b() && !mouse_down && ClickToFreeze &&!disableClickToFreeze))
4347 {
4348 oldtitle_version=title_version;
4349 System();
4350 }
4351
4352 9284954 mouse_down=gui_mouse_b();
4353
4354
1/2
✓ Branch 0 taken 9284954 times.
✗ Branch 1 not taken.
9284954 if(zc_read_system_key(KEY_F1))
4355 {
4356 if(zc_get_system_key(KEY_ZC_LCONTROL) || zc_get_system_key(KEY_ZC_RCONTROL))
4357 {
4358 halt=!halt;
4359 //zinit.subscreen=(zinit.subscreen+1)%ssdtMAX;
4360 }
4361 else
4362 {
4363 Throttlefps=!Throttlefps;
4364 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
4365 }
4366 }
4367
4368 // if(zc_readkey(KEY_F1)) Vsync=!Vsync;
4369 /*
4370 if(zc_readkey(KEY_F1)) set_bit(QHeader.rules4,qr4_NEWENEMYTILES,
4371 1-((get_bit(QHeader.rules4,qr4_NEWENEMYTILES))));
4372 */
4373
4374
1/2
✓ Branch 0 taken 9284954 times.
✗ Branch 1 not taken.
9284954 if(zc_read_system_key(KEY_F2))
4375 {
4376 ShowFPS=!ShowFPS;
4377 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
4378 }
4379
4380
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9284954 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9284954 if(zc_read_system_key(KEY_F3) && Playing) Paused=!Paused;
4381
4382
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9284954 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9284954 if(zc_read_system_key(KEY_F4) && Playing)
4383 {
4384 Paused=true;
4385 Advance=true;
4386 }
4387
4388
1/2
✓ Branch 0 taken 9284954 times.
✗ Branch 1 not taken.
9284954 if(zc_read_system_key(KEY_F6)) onTryQuit();
4389
4390 #ifndef ALLEGRO_MACOSX
4391
1/2
✓ Branch 0 taken 9284954 times.
✗ Branch 1 not taken.
9284954 if(zc_read_system_key(KEY_F9)) f_Quit(qRESET);
4392
4393
1/2
✓ Branch 0 taken 9284954 times.
✗ Branch 1 not taken.
9284954 if(zc_read_system_key(KEY_F10)) f_Quit(qEXIT);
4394 #else
4395 if(zc_read_system_key(KEY_F7)) f_Quit(qRESET);
4396
4397 if(zc_read_system_key(KEY_F8)) f_Quit(qEXIT);
4398 #endif
4399
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 9284954 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
9284954 if(zc_read_system_key(KEY_F5)&&(Playing && currscr<128 && DMaps[currdmap].flags&dmfVIEWMAP)) onSaveMapPic();
4400
4401
1/2
✓ Branch 0 taken 9284954 times.
✗ Branch 1 not taken.
9284954 if (zc_read_system_key(KEY_F12))
4402 {
4403 onSnapshot();
4404 }
4405
4406
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9284954 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9284954 if(debug_enabled && zc_read_system_key(KEY_TAB))
4407 set_debug(!get_debug());
4408
4409
1/2
✓ Branch 0 taken 9284954 times.
✗ Branch 1 not taken.
9284954 if(CheatModifierKeys())
4410 {
4411 for(Cheat c = (Cheat)1; c < Cheat::Last; c = (Cheat)(c+1))
4412 {
4413 if(!bindable_cheat(c))
4414 continue;
4415 if(get_debug() || cheat >= cheat_lvl(c))
4416 {
4417 if(checkcheat(c))
4418 cheats_hit_bind(c);
4419 }
4420 }
4421 }
4422
4423
1/2
✓ Branch 0 taken 9284954 times.
✗ Branch 1 not taken.
9284954 if(volkeys)
4424 {
4425 if(zc_read_system_key(KEY_PGUP)) master_volume(-1,midi_volume+8);
4426
4427 if(zc_read_system_key(KEY_PGDN)) master_volume(-1,midi_volume==255?248:midi_volume-8);
4428
4429 if(zc_read_system_key(KEY_HOME)) master_volume(digi_volume+8,-1);
4430
4431 if(zc_read_system_key(KEY_END)) master_volume(digi_volume==255?248:digi_volume-8,-1);
4432 }
4433
4434
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 9284954 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
9284954 if(!get_debug() || !SystemKeys || replay_is_replaying())
4435 9284954 goto bottom;
4436
4437 if(zc_readkey(KEY_D))
4438 {
4439 details = !details;
4440 rectfill(screen,0,0,319,7,BLACK);
4441 rectfill(screen,0,8,31,239,BLACK);
4442 rectfill(screen,288,8,319,239,BLACK);
4443 rectfill(screen,32,232,287,239,BLACK);
4444 }
4445
4446 if(zc_readkey(KEY_P)) Paused=!Paused;
4447
4448 //if(zc_readkey(KEY_P)) centerHero();
4449 if(zc_readkey(KEY_A))
4450 {
4451 Paused=true;
4452 Advance=true;
4453 }
4454
4455 if(zc_readkey(KEY_G)) db=(db==999)?0:999;
4456 #ifndef ALLEGRO_MACOSX
4457 if(zc_readkey(KEY_F8)) Showpal=!Showpal;
4458
4459 if(zc_readkey(KEY_F7))
4460 {
4461 Matrix(ss_speed, ss_density, 0);
4462 game_pal();
4463 }
4464 #else
4465 // The reason these are different on Mac in the first place is that
4466 // the OS doesn't let us use F9 and F10...
4467 if(zc_readkey(KEY_F10)) Showpal=!Showpal;
4468
4469 if(zc_readkey(KEY_F9))
4470 {
4471 Matrix(ss_speed, ss_density, 0);
4472 game_pal();
4473 }
4474 #endif
4475 if(zc_readkey(KEY_PLUS_PAD) || zc_readkey(KEY_EQUALS))
4476 {
4477 //change containers
4478 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4479 {
4480 //magic containers
4481 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4482 {
4483 game->set_maxmagic(zc_min(game->get_maxmagic()+game->get_mp_per_block(),game->get_mp_per_block()*8));
4484 }
4485 else
4486 {
4487 game->set_maxlife(zc_min(game->get_maxlife()+game->get_hp_per_heart(),game->get_hp_per_heart()*24));
4488 }
4489 }
4490 else
4491 {
4492 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4493 {
4494 game->set_magic(zc_min(game->get_magic()+1,game->get_maxmagic()));
4495 }
4496 else
4497 {
4498 game->set_life(zc_min(game->get_life()+1,game->get_maxlife()));
4499 }
4500 }
4501 }
4502
4503 if(zc_readkey(KEY_MINUS_PAD) || zc_readkey(KEY_MINUS))
4504 {
4505 //change containers
4506 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4507 {
4508 //magic containers
4509 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4510 {
4511 game->set_maxmagic(zc_max(game->get_maxmagic()-game->get_mp_per_block(),0));
4512 game->set_magic(zc_min(game->get_maxmagic(), game->get_magic()));
4513 //heart containers
4514 }
4515 else
4516 {
4517 game->set_maxlife(zc_max(game->get_maxlife()-game->get_hp_per_heart(),game->get_hp_per_heart()));
4518 game->set_life(zc_min(game->get_maxlife(), game->get_life()));
4519 }
4520 }
4521 else
4522 {
4523 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4524 {
4525 game->set_magic(zc_max(game->get_magic()-1,0));
4526 }
4527 else
4528 {
4529 game->set_life(zc_max(game->get_life()-1,0));
4530 }
4531 }
4532 }
4533
4534 if(zc_readkey(KEY_COMMA)) jukebox(currmidi-1);
4535
4536 if(zc_readkey(KEY_STOP)) jukebox(currmidi+1);
4537
4538 verifyBothWeapons();
4539
4540 bottom:
4541
4542
1/2
✓ Branch 0 taken 9284954 times.
✗ Branch 1 not taken.
9284954 if(input_idle(true) > after_time())
4543 {
4544 Matrix(ss_speed, ss_density, 0);
4545 game_pal();
4546 }
4547 9284954 }
4548
4549 708134 void checkQuitKeys()
4550 {
4551 #ifndef ALLEGRO_MACOSX
4552
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 708134 times.
708134 if(key[KEY_F9]) f_Quit(qRESET);
4553
4554
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 708134 times.
708134 if(key[KEY_F10]) f_Quit(qEXIT);
4555 #else
4556 if(key[KEY_F7]) f_Quit(qRESET);
4557
4558 if(key[KEY_F8]) f_Quit(qEXIT);
4559 #endif
4560 708134 }
4561
4562 9284954 bool CheatModifierKeys()
4563 {
4564 // Cheats are replayed via the X cheat step, no need to check for keyboard input
4565 // to trigger cheats.
4566
1/2
✓ Branch 0 taken 9284954 times.
✗ Branch 1 not taken.
9284954 if (replay_is_replaying())
4567 9284954 return false;
4568
4569 if ( ( cheat_modifier_keys[0] > 0 && key[cheat_modifier_keys[0]] ) ||
4570 ( cheat_modifier_keys[1] > 0 && key[cheat_modifier_keys[1]] ) ||
4571 (cheat_modifier_keys[0] <= 0 && cheat_modifier_keys[1] <= 0))
4572 {
4573 if ( ( cheat_modifier_keys[2] <= 0 || key[cheat_modifier_keys[2]] ) ||
4574 ( cheat_modifier_keys[3] > 0 && key[cheat_modifier_keys[3]] ) ||
4575 (cheat_modifier_keys[2] <= 0 && cheat_modifier_keys[3] <= 0))
4576 {
4577 return true;
4578 }
4579 }
4580 return false;
4581 9284954 }
4582
4583 //99:05:54, for some reason?
4584 #define OLDMAXTIME 21405240
4585 //9000:00:00, the highest even-thousand hour fitting within 32b signed. This is 375 *DAYS*.
4586 #define MAXTIME 1944000000
4587
4588 9285079 void advanceframe(bool allowwavy, bool sfxcleanup, bool allowF6Script)
4589 {
4590
2/2
✓ Branch 0 taken 9164956 times.
✓ Branch 1 taken 120123 times.
9285079 if(zcmusic!=NULL)
4591 {
4592 120123 zcmusic_poll();
4593 120123 }
4594 9285079 zcmixer_update(zcmixer, emusic_volume, FFCore.usr_music_volume, get_qr(qr_OLD_SCRIPT_VOLUME));
4595
4596 9285079 updatescr(allowwavy);
4597
4598 9285079 Advance=false;
4599
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 9285079 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 9285079 times.
9285079 while(Paused && !Advance && !Quit)
4600 {
4601 // have to call this, otherwise we'll get an infinite loop
4602 syskeys();
4603 if(allowF6Script)
4604 {
4605 FFCore.runF6Engine();
4606 }
4607 throttleFPS();
4608
4609 #ifdef _WIN32
4610
4611 if(use_dwm_flush)
4612 {
4613 do_DwmFlush();
4614 }
4615
4616 #endif
4617
4618 // to keep music playing
4619 if(zcmusic!=NULL)
4620 {
4621 zcmusic_poll();
4622 }
4623
4624 update_hw_screen();
4625 }
4626
4627
2/2
✓ Branch 0 taken 9284967 times.
✓ Branch 1 taken 112 times.
9285079 if(Quit)
4628 112 return;
4629
4630
3/4
✓ Branch 0 taken 8984007 times.
✓ Branch 1 taken 300960 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8984007 times.
9284967 if(Playing && game->get_time()<unsigned(get_qr(qr_GREATER_MAX_TIME) ? MAXTIME : OLDMAXTIME))
4631 8984007 game->change_time(1);
4632
4633 // Many mistakes have been make re: inputs, and we are stuck with many replays relying on those mistakes.
4634
4635 9284967 bool should_reset_down_state = !get_qr(qr_BROKEN_INPUT_DOWN_STATE);
4636
2/2
✓ Branch 0 taken 18170 times.
✓ Branch 1 taken 9266797 times.
9284967 if (replay_version_check(0, 16))
4637 9266797 should_reset_down_state = replay_version_check(11, 16);
4638
2/2
✓ Branch 0 taken 6949680 times.
✓ Branch 1 taken 2335287 times.
9284967 if (should_reset_down_state)
4639 {
4640
2/2
✓ Branch 0 taken 42035166 times.
✓ Branch 1 taken 2335287 times.
44370453 for (int i = 0; i < ZC_CONTROL_STATES; i++)
4641 42035166 down_control_states[i] = raw_control_state[i];
4642 2335287 }
4643
4644
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 9284954 times.
9284967 if (replay_is_active())
4645 {
4646
2/2
✓ Branch 0 taken 1270450 times.
✓ Branch 1 taken 8014504 times.
9284954 if (replay_version_check(3))
4647 8014504 replay_poll();
4648
4649
4/4
✓ Branch 0 taken 6946098 times.
✓ Branch 1 taken 2338856 times.
✓ Branch 2 taken 100535 times.
✓ Branch 3 taken 6845563 times.
9284954 if (replay_version_check(11) || replay_version_check(6, 8))
4650 2439391 replay_peek_input();
4651 9284954 }
4652
4653 9284967 load_control_called_this_frame = false;
4654
4655 9284967 poll_keyboard();
4656 9284967 update_keys();
4657
4658 9284967 ++frame;
4659
4660
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 9284954 times.
9284967 if (replay_is_replaying())
4661 9284954 replay_do_cheats();
4662 9284967 syskeys();
4663
4664 // The mouse variables can change from the mouse thread at anytime during a frame,
4665 // so save the result at the start so that replaying is consistent.
4666 9284967 script_mouse_x = gui_mouse_x();
4667 9284967 script_mouse_y = gui_mouse_y();
4668 9284967 script_mouse_z = mouse_z;
4669 9284967 script_mouse_b = mouse_b;
4670
4671 // Cheats used via the System menu (called by syskeys) will call cheats_enqueue. syskeys
4672 // is called just above, and in the paused loop above, so the queue-and-defer-slightly
4673 // approach here means it doesn't matter which call adds the cheat.
4674 9284967 cheats_execute_queued();
4675
4676
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 9284954 times.
9284967 if (replay_is_replaying())
4677 9284954 replay_peek_quit();
4678
2/2
✓ Branch 0 taken 9284954 times.
✓ Branch 1 taken 13 times.
9284967 if (GameFlags & GAMEFLAG_TRYQUIT)
4679 13 replay_step_quit(0);
4680
2/2
✓ Branch 0 taken 2933 times.
✓ Branch 1 taken 9282034 times.
9284967 if(allowF6Script)
4681 9282034 FFCore.runF6Engine();
4682
2/2
✓ Branch 0 taken 9284667 times.
✓ Branch 1 taken 300 times.
9284967 if (Quit)
4683 300 replay_step_quit(Quit);
4684 // Someday... maybe install a Turbo button here?
4685 9284967 throttleFPS();
4686
4687 #ifdef _WIN32
4688
4689 if(use_dwm_flush)
4690 {
4691 do_DwmFlush();
4692 }
4693
4694 #endif
4695
4696 //textprintf_ex(screen,font,0,72,254,BLACK,"%d %d", lastentrance, lastentrance_dmap);
4697
2/2
✓ Branch 0 taken 68757 times.
✓ Branch 1 taken 9216210 times.
9284967 if(sfxcleanup)
4698 9216210 sfx_cleanup();
4699
4700 9284967 jit_poll();
4701
4702 #ifdef __EMSCRIPTEN__
4703 // Yield the main thread back to the browser occasionally.
4704 if (is_headless())
4705 {
4706 static int rate = 10000;
4707 static int force_yield = rate;
4708 if (force_yield++ >= rate)
4709 {
4710 force_yield = 0;
4711 emscripten_sleep(0);
4712 }
4713 }
4714 #endif
4715 9285079 }
4716
4717 101 void zapout()
4718 {
4719 101 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4720 101 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4721
4722 101 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4723 101 script_drawing_commands.Clear();
4724
4725 // zap out
4726
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 2424 times.
2525 for(int32_t i=1; i<=24; i++)
4727 {
4728 2424 draw_fuzzy(i);
4729 2424 advanceframe(true);
4730
4731
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2424 times.
2424 if(Quit)
4732 {
4733 break;
4734 }
4735 2424 }
4736 101 }
4737
4738 101 void zapin()
4739 {
4740 101 FFCore.warpScriptCheck();
4741 101 draw_screen(tmpscr);
4742 101 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4743 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
4744 101 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4745
4746 // zap out
4747 101 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4748
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 2424 times.
2525 for(int32_t i=24; i>=1; i--)
4749 {
4750 2424 draw_fuzzy(i);
4751 2424 advanceframe(true);
4752
4753
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2424 times.
2424 if(Quit)
4754 {
4755 break;
4756 }
4757 2424 }
4758 101 }
4759
4760
4761 65 void wavyout(bool showhero)
4762 {
4763 65 draw_screen(tmpscr, showhero);
4764 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
4765
4766 65 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4767 65 clear_to_color(wavebuf,0);
4768 65 blit(framebuf,wavebuf,0,0,16,0,256,224);
4769
4770 static PALETTE wavepal;
4771
4772 int32_t ofs;
4773 65 int32_t amplitude=8;
4774
4775 65 int32_t wavelength=4;
4776 65 double palpos=0, palstep=4, palstop=126;
4777
4778 65 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4779
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 2730 times.
2795 for(int32_t i=0; i<168; i+=wavelength)
4780 {
4781
2/2
✓ Branch 0 taken 698880 times.
✓ Branch 1 taken 2730 times.
701610 for(int32_t l=0; l<256; l++)
4782 {
4783 698880 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4784 698880 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4785 698880 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4786 698880 }
4787
4788 2730 palpos+=palstep;
4789
4790
1/2
✓ Branch 0 taken 2730 times.
✗ Branch 1 not taken.
2730 if(palpos>=0)
4791 {
4792 2730 hw_palette = &wavepal;
4793 2730 update_hw_pal = true;
4794 2730 }
4795 else
4796 {
4797 hw_palette = &RAMpal;
4798 update_hw_pal = true;
4799 }
4800
4801
2/2
✓ Branch 0 taken 458640 times.
✓ Branch 1 taken 2730 times.
461370 for(int32_t j=0; j+playing_field_offset<224; j++)
4802 {
4803
2/2
✓ Branch 0 taken 117411840 times.
✓ Branch 1 taken 458640 times.
117870480 for(int32_t k=0; k<256; k++)
4804 {
4805 117411840 ofs=0;
4806
4807
4/4
✓ Branch 0 taken 57308160 times.
✓ Branch 1 taken 60103680 times.
✓ Branch 2 taken 28654080 times.
✓ Branch 3 taken 28654080 times.
117411840 if((j<i)&&(j&1))
4808 {
4809 28654080 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4810 28654080 }
4811
4812 117411840 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4813 117411840 }
4814 458640 }
4815
4816 2730 advanceframe(true);
4817
4818 // animate_combos();
4819
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2730 times.
2730 if(Quit)
4820 break;
4821 2730 }
4822
4823 65 destroy_bitmap(wavebuf);
4824 65 }
4825
4826 65 void wavyin()
4827 {
4828 65 draw_screen(tmpscr);
4829 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
4830
4831 65 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4832 65 clear_to_color(wavebuf,0);
4833 65 blit(framebuf,wavebuf,0,0,16,0,256,224);
4834
4835 static PALETTE wavepal;
4836
4837 //Breaks dark rooms.
4838 //In any case I don't think we need this, since palette is already loaded in doWarp() (famous last words...) -DD
4839 /*
4840 loadfullpal();
4841 loadlvlpal(DMaps[currdmap].color);
4842 ringcolor(false);
4843 */
4844 65 refreshpal=false;
4845 int32_t ofs;
4846 65 int32_t amplitude=8;
4847 65 int32_t wavelength=4;
4848 65 double palpos=168, palstep=4, palstop=126;
4849
4850 65 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4851
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 2730 times.
2795 for(int32_t i=0; i<168; i+=wavelength)
4852 {
4853
2/2
✓ Branch 0 taken 698880 times.
✓ Branch 1 taken 2730 times.
701610 for(int32_t l=0; l<256; l++)
4854 {
4855 698880 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4856 698880 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4857 698880 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4858 698880 }
4859
4860 2730 palpos-=palstep;
4861
4862
1/2
✓ Branch 0 taken 2730 times.
✗ Branch 1 not taken.
2730 if(palpos>=0)
4863 {
4864 2730 hw_palette = &wavepal;
4865 2730 update_hw_pal = true;
4866 2730 }
4867 else
4868 {
4869 hw_palette = &RAMpal;
4870 update_hw_pal = true;
4871 }
4872
4873
2/2
✓ Branch 0 taken 458640 times.
✓ Branch 1 taken 2730 times.
461370 for(int32_t j=0; j+playing_field_offset<224; j++)
4874 {
4875
2/2
✓ Branch 0 taken 117411840 times.
✓ Branch 1 taken 458640 times.
117870480 for(int32_t k=0; k<256; k++)
4876 {
4877 117411840 ofs=0;
4878
4879
4/4
✓ Branch 0 taken 59404800 times.
✓ Branch 1 taken 58007040 times.
✓ Branch 2 taken 30051840 times.
✓ Branch 3 taken 29352960 times.
117411840 if((j<(167-i))&&(j&1))
4880 {
4881 29352960 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4882 29352960 }
4883
4884 117411840 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4885 117411840 }
4886 458640 }
4887
4888 2730 advanceframe(true);
4889 // animate_combos();
4890
4891
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2730 times.
2730 if(Quit)
4892 break;
4893 2730 }
4894
4895 65 destroy_bitmap(wavebuf);
4896 65 }
4897
4898 2168 void blackscr(int32_t fcnt,bool showsubscr)
4899 {
4900 2168 reset_pal_cycling();
4901 2168 script_drawing_commands.Clear();
4902
4903 2168 FFCore.warpScriptCheck();
4904 2168 bool showtime = game->should_show_time();
4905
2/2
✓ Branch 0 taken 2168 times.
✓ Branch 1 taken 64970 times.
67138 while(fcnt>0)
4906 {
4907 64970 clear_bitmap(framebuf);
4908
4909
2/2
✓ Branch 0 taken 25080 times.
✓ Branch 1 taken 39890 times.
64970 if(showsubscr)
4910 {
4911 39890 put_passive_subscr(framebuf,0,passive_subscreen_offset,showtime,sspUP);
4912
3/4
✓ Branch 0 taken 39890 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 750 times.
✓ Branch 3 taken 39140 times.
39890 if(get_qr(qr_SCRIPTDRAWSINWARPS) || (get_qr(qr_PASSIVE_SUBSCRIPT_RUNS_WHEN_GAME_IS_FROZEN)))
4913 {
4914 750 do_script_draws(framebuf, tmpscr, 0, playing_field_offset);
4915 750 }
4916 39890 }
4917
4918 64970 advanceframe(true);
4919
4920
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64970 times.
64970 if(Quit)
4921 break;
4922
4923 64970 --fcnt;
4924 }
4925 2168 }
4926
4927 1011 void openscreen(int32_t shape)
4928 {
4929 1011 reset_pal_cycling();
4930 1011 black_opening_count=0;
4931
4932
3/4
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 911 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 100 times.
1011 if(COOLSCROLL || shape>-1)
4933 {
4934 911 open_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
4935 911 return;
4936 }
4937 else
4938 {
4939 100 Hero.setDontDraw(true);
4940 100 show_subscreen_dmap_dots=false;
4941 100 show_subscreen_numbers=false;
4942 // show_subscreen_items=false;
4943 100 show_subscreen_life=false;
4944 }
4945
4946 100 int32_t x=128;
4947
4948 100 FFCore.warpScriptCheck();
4949
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 8000 times.
8100 for(int32_t i=0; i<80; i++)
4950 {
4951 8000 draw_screen(tmpscr);
4952 //? draw_screen already draws the subscreen -DD
4953 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
4954 8000 x=128-(((i*128/80)/8)*8);
4955
4956
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8000 times.
8000 if(x>0)
4957 {
4958 8000 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
4959 8000 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
4960 8000 }
4961
4962 8000 advanceframe(true);
4963
4964
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8000 times.
8000 if(Quit)
4965 {
4966 break;
4967 }
4968 8000 }
4969
4970 100 Hero.setDontDraw(false);
4971 100 show_subscreen_items=true;
4972 100 show_subscreen_dmap_dots=true;
4973 1011 }
4974
4975 void closescreen(int32_t shape)
4976 {
4977 reset_pal_cycling();
4978 black_opening_count=0;
4979
4980 if(COOLSCROLL || shape>-1)
4981 {
4982 close_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
4983 return;
4984 }
4985 else
4986 {
4987 Hero.setDontDraw(true);
4988 show_subscreen_dmap_dots=false;
4989 show_subscreen_numbers=false;
4990 // show_subscreen_items=false;
4991 show_subscreen_life=false;
4992 }
4993
4994 int32_t x=128;
4995
4996 FFCore.warpScriptCheck();
4997 for(int32_t i=79; i>=0; --i)
4998 {
4999 draw_screen(tmpscr);
5000 //? draw_screen already draws the subscreen -DD
5001 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
5002 x=128-(((i*128/80)/8)*8);
5003
5004 if(x>0)
5005 {
5006 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
5007 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
5008 }
5009
5010 advanceframe(true);
5011
5012 if(Quit)
5013 {
5014 break;
5015 }
5016 }
5017
5018 Hero.setDontDraw(false);
5019 show_subscreen_items=true;
5020 show_subscreen_dmap_dots=true;
5021 }
5022
5023 179 int32_t TriforceCount()
5024 {
5025 179 int32_t c=0;
5026
5027
2/2
✓ Branch 0 taken 1432 times.
✓ Branch 1 taken 179 times.
1611 for(int32_t i=1; i<=8; i++)
5028
2/2
✓ Branch 0 taken 388 times.
✓ Branch 1 taken 1044 times.
2476 if(game->lvlitems[i]&liTRIFORCE)
5029 1044 ++c;
5030
5031 179 return c;
5032 }
5033
5034 int32_t onCustomGame()
5035 {
5036 int32_t file = getsaveslot();
5037
5038 if(file < 0)
5039 return D_O_K;
5040
5041 bool ret = (custom_game(file)!=0);
5042 return ret ? D_CLOSE : D_O_K;
5043 }
5044
5045 int32_t onContinue()
5046 {
5047 return D_CLOSE;
5048 }
5049
5050 int32_t onEsc() // Unused?? -L
5051 {
5052 return zc_getrawkey(KEY_ESC, true)?D_CLOSE:D_O_K;
5053 }
5054
5055 int32_t onVsync()
5056 {
5057 Throttlefps = !Throttlefps;
5058 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
5059 return D_O_K;
5060 }
5061
5062 int32_t onWinPosSave()
5063 {
5064 SaveWinPos = !SaveWinPos;
5065 zc_set_config(cfg_sect,"save_window_position",(int32_t)SaveWinPos);
5066 return D_O_K;
5067 }
5068 int32_t onIntegerScaling()
5069 {
5070 scaleForceInteger = !scaleForceInteger;
5071 zc_set_config("zeldadx","scaling_force_integer",(int)scaleForceInteger);
5072 return D_O_K;
5073 }
5074 int32_t onStretchGame()
5075 {
5076 stretchGame = !stretchGame;
5077 zc_set_config("zeldadx","stretch_game_area",stretchGame?1:0);
5078 return D_O_K;
5079 }
5080
5081 int32_t onClickToFreeze()
5082 {
5083 ClickToFreeze = !ClickToFreeze;
5084 zc_set_config(cfg_sect,"clicktofreeze", (int32_t)ClickToFreeze);
5085 return D_O_K;
5086 }
5087
5088 int32_t OnSaveZCConfig()
5089 {
5090 if(jwin_alert3(
5091 "Save Configuration",
5092 "Are you sure that you wish to save your present configuration settings?",
5093 "This will overwrite your prior settings!",
5094 NULL,
5095 "&Yes",
5096 "&No",
5097 NULL,
5098 'y',
5099 'n',
5100 0,
5101 get_zc_font(font_lfont)) == 1)
5102 {
5103 save_game_configs();
5104 return D_O_K;
5105 }
5106 else return D_O_K;
5107 }
5108
5109 int32_t OnnClearQuestDir()
5110 {
5111 if(jwin_alert3(
5112 "Clear Current Directory Cache",
5113 "Are you sure that you wish to clear the current cached directory?",
5114 "This will default the current directory to the ROOT for this instance of ZC Player!",
5115 NULL,
5116 "&Yes",
5117 "&No",
5118 NULL,
5119 'y',
5120 'n',
5121 0,
5122 get_zc_font(font_lfont)) == 1)
5123 {
5124 zc_set_config("zeldadx","win_qst_dir","");
5125 flush_config_file();
5126 strcpy(qstdir,"");
5127 #ifdef __EMSCRIPTEN__
5128 em_sync_fs();
5129 #endif
5130 return D_O_K;
5131 }
5132 else return D_O_K;
5133 }
5134
5135
5136 int32_t onConsoleZASM()
5137 {
5138 if ( !zasm_debugger )
5139 {
5140 AlertDialog("WARNING: ZASM Debugger",
5141 "Enabling this will open the ZASM Debugger Console"
5142 "\nThis will likely grind ZC to a halt with lag."
5143 "\nTo make any use of this, it is suggested that you read"
5144 "\nthe documentation for 'void Breakpoint(char[] string);'"
5145 " in 'ZScript_Additions.txt'"
5146 "\nThis is not recommended for normal users,"
5147 " and is only intended for ZC developers,"
5148 "\nor quest developers coding directly in ZASM"
5149 "\nAre you sure that you wish to open the ZASM Debugger?",
5150 [&](bool ret,bool)
5151 {
5152 if(ret)
5153 {
5154 FFCore.ZASMPrint(true);
5155 }
5156 }).show();
5157 return D_O_K;
5158 }
5159 else
5160 {
5161 FFCore.ZASMPrint(false);
5162 return D_O_K;
5163 }
5164 }
5165
5166
5167 int32_t onConsoleZScript()
5168 {
5169 if ( !zscript_debugger )
5170 {
5171 AlertDialog("ZScript Debugger",
5172 "Enabling this will open the ZScript Debugger Console"
5173 "\nThis will display any messages logged by scripts,"
5174 " including script errors."
5175 "\nAre you sure that you wish to open the ZScript Debugger?",
5176 [&](bool ret,bool)
5177 {
5178 if(ret)
5179 {
5180 FFCore.ZScriptConsole(true);
5181 }
5182 }).show();
5183 return D_O_K;
5184 }
5185 else
5186 {
5187 FFCore.ZScriptConsole(false);
5188 return D_O_K;
5189 }
5190 }
5191
5192 int32_t onClrConsoleOnReload()
5193 {
5194 clearConsoleOnReload = !clearConsoleOnReload;
5195 zc_set_config("CONSOLE","clear_console_on_reload",clearConsoleOnReload?1:0);
5196 return D_O_K;
5197 }
5198 int32_t onClrConsoleOnLoad()
5199 {
5200 clearConsoleOnLoad = !clearConsoleOnLoad;
5201 zc_set_config("CONSOLE","clear_console_on_load",clearConsoleOnLoad?1:0);
5202 return D_O_K;
5203 }
5204
5205
5206 int32_t onFrameSkip()
5207 {
5208 FrameSkip = !FrameSkip;
5209 return D_O_K;
5210 }
5211
5212 int32_t onSaveDragResize()
5213 {
5214 SaveDragResize = !SaveDragResize;
5215 zc_set_config(cfg_sect,"save_drag_resize",(int32_t)SaveDragResize);
5216 return D_O_K;
5217 }
5218
5219 int32_t onDragAspect()
5220 {
5221 DragAspect = !DragAspect;
5222 zc_set_config(cfg_sect,"drag_aspect",(int32_t)DragAspect);
5223 return D_O_K;
5224 }
5225
5226 int32_t onTransLayers()
5227 {
5228 TransLayers = !TransLayers;
5229 zc_set_config(cfg_sect,"translayers",(int32_t)TransLayers);
5230 return D_O_K;
5231 }
5232
5233 int32_t onNESquit()
5234 {
5235 NESquit = !NESquit;
5236 zc_set_config(cfg_sect,"fastquit",(int32_t)NESquit);
5237 return D_O_K;
5238 }
5239
5240 int32_t onVolKeys()
5241 {
5242 volkeys = !volkeys;
5243 zc_set_config(sfx_sect,"volkeys",(int32_t)volkeys);
5244 return D_O_K;
5245 }
5246
5247 int32_t onShowFPS()
5248 {
5249 ShowFPS = !ShowFPS;
5250 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
5251 return D_O_K;
5252 }
5253
5254 1095624572 bool is_Fkey(int32_t k)
5255 {
5256
2/2
✓ Branch 0 taken 111419448 times.
✓ Branch 1 taken 984205124 times.
1095624572 switch(k)
5257 {
5258 case KEY_F1:
5259 case KEY_F2:
5260 case KEY_F3:
5261 case KEY_F4:
5262 case KEY_F5:
5263 case KEY_F6:
5264 case KEY_F7:
5265 case KEY_F8:
5266 case KEY_F9:
5267 case KEY_F10:
5268 case KEY_F11:
5269 case KEY_F12:
5270 111419448 return true;
5271 }
5272
5273 984205124 return false;
5274 1095624572 }
5275
5276 void kb_getkey(DIALOG *d);
5277
5278 //Used by all keyboard key settings dialogues.
5279 void kb_clearjoystick(DIALOG *d)
5280 {
5281 d->flags|=D_SELECTED;
5282
5283 jwin_button_proc(MSG_DRAW,d,0);
5284 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 168, 48, FR_WIN);
5285 // text_mode(vc(11));
5286 textout_centre_ex(gui_bmp, font, "Press any key to clear", gui_bmp->w/2, gui_bmp->h/2 - 8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5287 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, gui_bmp->h/2, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5288
5289 update_hw_screen(true);
5290
5291 clear_keybuf();
5292 int32_t k = next_press_key();
5293 clear_keybuf();
5294
5295 //shnarf
5296 //47=f1
5297 //59=esc
5298 // if(k>0 && k<123 && !((k>46)&&(k<60)))
5299 // *((int32_t*)d->dp3) = k;
5300 if ( k != 59 ) *((int32_t*)d->dp3) = 0;
5301
5302
5303 d->flags&=~D_SELECTED;
5304 }
5305
5306 //Clears key to 0.
5307 //Used by all keyboard key settings dialogues.
5308 void kb_clearkey(DIALOG *d);
5309
5310 int32_t d_j_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5311 {
5312 switch(msg)
5313 {
5314 case MSG_KEY:
5315 case MSG_CLICK:
5316
5317 kb_clearjoystick(d);
5318
5319 while(gui_mouse_b())
5320 {
5321 clear_keybuf();
5322 rest(1);
5323 }
5324
5325 return D_REDRAW;
5326 }
5327
5328 return jwin_button_proc(msg,d,c);
5329 }
5330
5331 int32_t d_kbutton_proc(int32_t msg,DIALOG *d,int32_t c);
5332 //Only used in keyboard settings dialogues to clear keys.
5333 int32_t d_k_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c);
5334
5335 void j_getbtn(DIALOG *d)
5336 {
5337 d->flags|=D_SELECTED;
5338 jwin_button_proc(MSG_DRAW,d,0);
5339 jwin_draw_win(screen, (screen->w-160)/2, (screen->h-48)/2, 160, 48, FR_WIN);
5340 // text_mode(vc(11));
5341 int32_t y = screen->h/2 - 12;
5342 textout_centre_ex(screen, font, "Press a button", screen->w/2, y, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5343 textout_centre_ex(screen, font, "ESC to cancel", screen->w/2, y+8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5344 textout_centre_ex(screen, font, "SPACE to disable", screen->w/2, y+16, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5345
5346 update_hw_screen(true);
5347
5348 int32_t b = next_press_btn();
5349
5350 if(b>=0)
5351 *((int32_t*)d->dp3) = b;
5352
5353 d->flags&=~D_SELECTED;
5354
5355 if (player)
5356 player->joy_on = TRUE;
5357 }
5358
5359 int32_t d_jbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5360 {
5361 switch(msg)
5362 {
5363 case MSG_KEY:
5364 case MSG_CLICK:
5365
5366 j_getbtn(d);
5367
5368 while(gui_mouse_b()) {
5369 rest(1);
5370 clear_keybuf();
5371 }
5372
5373 return D_REDRAW;
5374 }
5375
5376 return jwin_button_proc(msg,d,c);
5377 }
5378
5379 //shnarf
5380 extern const char *key_str[];
5381 std::string get_keystr(int key);
5382
5383 const char *pan_str[4] = { "MONO", " 1/2", " 3/4", "FULL" };
5384 //extern int32_t zcmusic_bufsz;
5385
5386 static char str_a[80],str_b[80],str_s[80],str_m[80],str_l[80],str_r[80],str_p[80],str_ex1[80],str_ex2[80],str_ex3[80],str_ex4[80],
5387 str_leftmod1[80],str_leftmod2[80],str_rightmod1[80],str_rightmod2[80], str_left[80], str_right[80], str_up[80], str_down[80];
5388
5389 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c)
5390 {
5391 //these are here to bypass compiler warnings about unused arguments
5392 c=c;
5393
5394 if(msg==MSG_DRAW)
5395 {
5396 switch(d->w)
5397 {
5398 case 0:
5399 sprintf(str_a,"%03d\n%s",Akey,key_str[Akey]);
5400 sprintf(str_b,"%03d\n%s",Bkey,key_str[Bkey]);
5401 sprintf(str_s,"%03d\n%s",Skey,key_str[Skey]);
5402 sprintf(str_l,"%03d\n%s",Lkey,key_str[Lkey]);
5403 sprintf(str_r,"%03d\n%s",Rkey,key_str[Rkey]);
5404 sprintf(str_p,"%03d\n%s",Pkey,key_str[Pkey]);
5405 sprintf(str_ex1,"%03d\n%s",Exkey1,key_str[Exkey1]);
5406 sprintf(str_ex2,"%03d\n%s",Exkey2,key_str[Exkey2]);
5407 sprintf(str_ex3,"%03d\n%s",Exkey3,key_str[Exkey3]);
5408 sprintf(str_ex4,"%03d\n%s",Exkey4,key_str[Exkey4]);
5409 sprintf(str_up,"%03d\n%s",DUkey,key_str[DUkey]);
5410 sprintf(str_down,"%03d\n%s",DDkey,key_str[DDkey]);
5411 sprintf(str_left,"%03d\n%s",DLkey,key_str[DLkey]);
5412 sprintf(str_right,"%03d\n%s",DRkey,key_str[DRkey]);
5413 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5414 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5415 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5416 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5417 break;
5418
5419 case 1:
5420 sprintf(str_a,"%03d\n%s",Abtn,joybtn_name(Abtn));
5421 sprintf(str_b,"%03d\n%s",Bbtn,joybtn_name(Bbtn));
5422 sprintf(str_s,"%03d\n%s",Sbtn,joybtn_name(Sbtn));
5423 sprintf(str_l,"%03d\n%s",Lbtn,joybtn_name(Lbtn));
5424 sprintf(str_r,"%03d\n%s",Rbtn,joybtn_name(Rbtn));
5425 sprintf(str_m,"%03d\n%s",Mbtn,joybtn_name(Mbtn));
5426 sprintf(str_p,"%03d\n%s",Pbtn,joybtn_name(Pbtn));
5427 sprintf(str_ex1,"%03d\n%s",Exbtn1,joybtn_name(Exbtn1));
5428 sprintf(str_ex2,"%03d\n%s",Exbtn2,joybtn_name(Exbtn2));
5429 sprintf(str_ex3,"%03d\n%s",Exbtn3,joybtn_name(Exbtn3));
5430 sprintf(str_ex4,"%03d\n%s",Exbtn4,joybtn_name(Exbtn4));
5431 sprintf(str_up,"%03d\n%s",DUbtn,joybtn_name(DUbtn));
5432 sprintf(str_down,"%03d\n%s",DDbtn,joybtn_name(DDbtn));
5433 sprintf(str_left,"%03d\n%s",DLbtn,joybtn_name(DLbtn));
5434 sprintf(str_right,"%03d\n%s",DRbtn,joybtn_name(DRbtn));
5435 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5436 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5437 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5438 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5439 break;
5440
5441 case 2:
5442 sprintf(str_a," %3d",midi_volume);
5443 sprintf(str_b," %3d",digi_volume);
5444 sprintf(str_l," %3d",emusic_volume);
5445 sprintf(str_m," %3dKB",zcmusic_bufsz);
5446 sprintf(str_r," %3d",sfx_volume);
5447 strcpy(str_s,pan_str[pan_style]);
5448 sprintf(str_leftmod1,"%3d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5449 sprintf(str_leftmod2,"%3d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5450 sprintf(str_rightmod1,"%3d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5451 sprintf(str_rightmod2,"%3d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5452 break;
5453 }
5454 }
5455
5456 return D_O_K;
5457 }
5458
5459 int32_t set_vol(void *dp3, int32_t d2)
5460 {
5461 switch(((int32_t*)dp3)[0])
5462 {
5463 case 0:
5464 midi_volume = zc_min(d2<<3,255);
5465 break;
5466
5467 case 1:
5468 digi_volume = zc_min(d2<<3,255);
5469 break;
5470
5471 case 2:
5472 emusic_volume = zc_min(d2<<3,255);
5473 break;
5474
5475 case 3:
5476 sfx_volume = zc_min(d2<<3,255);
5477 break;
5478 }
5479
5480 // text_mode(vc(11));
5481 textprintf_right_ex(screen,get_zc_font(font_lfont_l), ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3d",zc_min(d2<<3,255));
5482 return D_O_K;
5483 }
5484
5485 int32_t set_pan(void *dp3, int32_t d2)
5486 {
5487 pan_style = vbound(d2,0,3);
5488 // text_mode(vc(11));
5489 textout_right_ex(screen,get_zc_font(font_lfont_l), pan_str[pan_style],((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5490 return D_O_K;
5491 }
5492
5493 int32_t set_buf(void *dp3, int32_t d2)
5494 {
5495 // text_mode(vc(11));
5496 zcmusic_bufsz = d2 + 1;
5497 textprintf_right_ex(screen,get_zc_font(font_lfont_l), ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3dKB",zcmusic_bufsz);
5498 return D_O_K;
5499 }
5500
5501 static int32_t gamepad_btn_list[] =
5502 {
5503 6,
5504 7,8,9,10,11,12,13,14,15,16,17,
5505 18,19,20,21,22,23,24,25,26,27,28,
5506 29,30,31,32,33,34,35,36,37,38,39,
5507 -1
5508 };
5509
5510 static int32_t gamepad_dirs_list[] =
5511 {
5512 40,41,42,43,
5513 44,45,46,47,
5514 48,49,50,51,
5515 52,53,54,55,
5516 56,
5517 -1
5518 };
5519
5520 static TABPANEL gamepad_tabs[] =
5521 {
5522 // (text)
5523 { (char *)"Buttons", D_SELECTED, gamepad_btn_list, 0, NULL },
5524 { (char *)"Directions", 0, gamepad_dirs_list, 0, NULL },
5525 { NULL, 0, NULL, 0, NULL }
5526 };
5527
5528 static DIALOG gamepad_dlg[] =
5529 {
5530 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5531 { jwin_win_proc, 8, 24, 304, 256, 0, 0, 0, D_EXIT, 0, 0, (void *) "Gamepad Controls", NULL, NULL },
5532 { jwin_tab_proc, 8+4, 24+23,304-8,256-52,vc(0), vc(15), 0, 0, 0, 0, (void *) gamepad_tabs, NULL, (void *)gamepad_dlg },
5533 { d_stringloader, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5534 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5535 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5536 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5537 // 6
5538 { d_dummy_proc, 14, 61, 294, 192, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5539 // 7
5540 { jwin_ctext_proc, 92, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5541 { jwin_ctext_proc, 92, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5542 { jwin_ctext_proc, 92, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5543 { jwin_ctext_proc, 92, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5544 { jwin_ctext_proc, 92, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5545 { jwin_ctext_proc, 237, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5546 { jwin_ctext_proc, 237, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5547 { jwin_ctext_proc, 237, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5548 { jwin_ctext_proc, 237, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5549 { jwin_ctext_proc, 237, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5550 { jwin_ctext_proc, 92, 244-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_m, NULL, NULL },
5551 // 18
5552 { d_jbutton_proc, 22, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Abtn},
5553 { d_jbutton_proc, 22, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bbtn},
5554 { d_jbutton_proc, 22, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Sbtn},
5555 { d_jbutton_proc, 22, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exbtn1},
5556 { d_jbutton_proc, 22, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exbtn3},
5557 { d_jbutton_proc, 167, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lbtn},
5558 { d_jbutton_proc, 167, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rbtn},
5559 { d_jbutton_proc, 167, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pbtn},
5560 { d_jbutton_proc, 167, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exbtn2},
5561 { d_jbutton_proc, 167, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exbtn4},
5562 { d_jbutton_proc, 22, 242-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Menu", NULL, &Mbtn},
5563 // 29
5564 { d_j_clearbutton_proc, 22+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Abtn},
5565 { d_j_clearbutton_proc, 22+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bbtn},
5566 { d_j_clearbutton_proc, 22+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Sbtn},
5567 { d_j_clearbutton_proc, 22+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn1},
5568 { d_j_clearbutton_proc, 22+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn3},
5569 { d_j_clearbutton_proc, 167+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lbtn},
5570 { d_j_clearbutton_proc, 167+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rbtn},
5571 { d_j_clearbutton_proc, 167+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pbtn},
5572 { d_j_clearbutton_proc, 167+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn2},
5573 { d_j_clearbutton_proc, 167+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn4},
5574 { d_j_clearbutton_proc, 22+91, 242-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Mbtn},
5575 // 40
5576 { jwin_frame_proc, 14, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5577 { jwin_frame_proc, 159, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5578 { jwin_text_proc, 30, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5579 { jwin_text_proc, 175, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5580 // 44
5581 { jwin_text_proc, 92, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5582 { jwin_text_proc, 92, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5583 { jwin_text_proc, 237, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5584 { jwin_text_proc, 237, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5585 // 48
5586 { d_jbutton_proc, 22, 82, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUbtn },
5587 { d_jbutton_proc, 22, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDbtn },
5588 { d_jbutton_proc, 167, 82, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLbtn },
5589 { d_jbutton_proc, 167, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRbtn },
5590 // 52
5591 { d_j_clearbutton_proc, 22+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUbtn},
5592 { d_j_clearbutton_proc, 22+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDbtn},
5593 { d_j_clearbutton_proc, 167+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLbtn},
5594 { d_j_clearbutton_proc, 167+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRbtn},
5595 // 56
5596 { jwin_check_proc, 22, 150, 147, 8, vc(14), vc(1), 0, 0, 1, 0, (void *) "Use Analog Stick/DPad", NULL, NULL },
5597 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5598 };
5599
5600 static int32_t keyboard_keys_list[] =
5601 {
5602 6,7,8,9,10,
5603 11,12,13,14,15,16,17,18,19,20,
5604 21,22,23,24,25,26,27,28,29,30,
5605 31,32,33,34,35,36,37,38,39,40,
5606 -1
5607 };
5608
5609 static int32_t keyboard_dirs_list[] =
5610 {
5611 41,42,43,44,
5612 45,46,47,48,
5613 49,50,51,52,
5614 53,54,55,56,
5615 -1
5616 };
5617
5618 static int32_t keyboard_mods_list[] =
5619 {
5620 57,58,59,60,
5621 61,62,63,64,
5622 65,66,67,68,
5623 69,70,71,72,
5624 -1
5625 };
5626
5627 static TABPANEL keyboard_control_tabs[] =
5628 {
5629 // (text)
5630 { (char *)"Keys", D_SELECTED, keyboard_keys_list, 0, NULL },
5631 { (char *)"Directions", 0, keyboard_dirs_list, 0, NULL },
5632 { (char *)"Cheat Mods", 0, keyboard_mods_list, 0, NULL },
5633 { NULL, 0, NULL, 0, NULL }
5634 };
5635
5636 static DIALOG keyboard_control_dlg[] =
5637 {
5638 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5639 { jwin_win_proc, 8, 39, 304, 240, 0, 0, 0, D_EXIT, 0, 0, (void *) "Keyboard Controls", NULL, NULL },
5640 { jwin_tab_proc, 8+4, 39+23,304-8,240-56,vc(0), vc(15), 0, 0, 0, 0, (void *) keyboard_control_tabs, NULL, (void *)keyboard_control_dlg },
5641 { d_stringloader, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5642 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5643 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5644 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5645 // Keys
5646 // 6
5647 { jwin_frame_proc, 14, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5648 { jwin_frame_proc, 158, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5649 { jwin_frame_proc, 14, 181, 292, 67, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5650 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Standard", NULL, NULL },
5651 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Extended", NULL, NULL },
5652 // 11
5653 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5654 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5655 { jwin_text_proc, 92-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5656 { jwin_text_proc, 92-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5657 { jwin_text_proc, 92-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5658 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5659 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5660 { jwin_text_proc, 237-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5661 { jwin_text_proc, 237-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5662 { jwin_text_proc, 237-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5663 // 21
5664 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Akey},
5665 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bkey},
5666 { d_kbutton_proc, 22, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Skey},
5667 { d_kbutton_proc, 22, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exkey1},
5668 { d_kbutton_proc, 22, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exkey3},
5669 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lkey},
5670 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rkey},
5671 { d_kbutton_proc, 167, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pkey},
5672 { d_kbutton_proc, 167, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exkey2},
5673 { d_kbutton_proc, 167, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exkey4},
5674 // 31
5675 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Akey},
5676 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bkey},
5677 { d_k_clearbutton_proc, 22+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Skey},
5678 { d_k_clearbutton_proc, 22+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey1},
5679 { d_k_clearbutton_proc, 22+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey3},
5680 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lkey},
5681 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rkey},
5682 { d_k_clearbutton_proc, 167+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pkey},
5683 { d_k_clearbutton_proc, 167+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey2},
5684 { d_k_clearbutton_proc, 167+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey4},
5685 // Dirs
5686 // 41
5687 { jwin_frame_proc, 14, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5688 { jwin_frame_proc, 159, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5689 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5690 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5691 // 45
5692 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5693 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5694 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5695 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5696 // 49
5697 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUkey},
5698 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDkey},
5699 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLkey},
5700 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRkey},
5701 // 53
5702 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUkey},
5703 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDkey},
5704 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLkey},
5705 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRkey},
5706 // Mods
5707 // 57
5708 { jwin_frame_proc, 14, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5709 { jwin_frame_proc, 158, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5710 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Left", NULL, NULL },
5711 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Right", NULL, NULL },
5712 // 61
5713 { jwin_text_proc, 92-26, 101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod1, NULL, NULL },
5714 { jwin_text_proc, 92-26, 129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod1, NULL, NULL },
5715 { jwin_text_proc, 237-4-22,101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod2, NULL, NULL },
5716 { jwin_text_proc, 237-4-22,129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod2, NULL, NULL },
5717 // 65
5718 { d_kbutton_proc, 22, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[0]},
5719 { d_kbutton_proc, 22, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[2]},
5720 { d_kbutton_proc, 167, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[1]},
5721 { d_kbutton_proc, 167, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[3]},
5722 // 69
5723 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[0]},
5724 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[2]},
5725 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[1]},
5726 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[3]},
5727 // 73
5728 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5729 };
5730
5731 /*
5732 int32_t midi_dp[3] = {0,147,104};
5733 int32_t digi_dp[3] = {1,147,120};
5734 int32_t pan_dp[3] = {0,147,136};
5735 int32_t buf_dp[3] = {0,147,152};
5736 */
5737 int32_t midi_dp[3] = {0,0,0};
5738 int32_t digi_dp[3] = {1,0,0};
5739 int32_t emus_dp[3] = {2,0,0};
5740 int32_t buf_dp[3] = {0,0,0};
5741 int32_t sfx_dp[3] = {3,0,0};
5742 int32_t pan_dp[3] = {0,0,0};
5743
5744 static DIALOG sound_dlg[] =
5745 {
5746 //(dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5747 116 { jwin_win_proc, 0, 0, 320, 178, 0, 0, 0, D_EXIT, 0, 0, (void *) "Sound Settings", NULL, NULL },
5748 116 { d_stringloader, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5749 116 { jwin_button_proc, 58, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5750 116 { jwin_button_proc, 138, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5751 116 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5752 116 { jwin_frame_proc, 10, 28, 300, 112, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
5753 116 { jwin_rtext_proc, 190, 40, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_a, NULL, NULL },
5754 116 { jwin_rtext_proc, 190, 56, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_b, NULL, NULL },
5755 116 { jwin_rtext_proc, 190, 72, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_l, NULL, NULL },
5756 116 { jwin_rtext_proc, 190, 88, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_m, NULL, NULL },
5757 // 10
5758 116 { jwin_rtext_proc, 190, 104, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_r, NULL, NULL },
5759 116 { jwin_rtext_proc, 190, 120, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_s, NULL, NULL },
5760 116 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5761 116 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5762 116 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5763 116 { jwin_slider_proc, 196, 40, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, midi_dp },
5764 116 { jwin_slider_proc, 196, 56, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, digi_dp },
5765 116 { jwin_slider_proc, 196, 72, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, emus_dp },
5766 116 { jwin_slider_proc, 196, 88, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 127, 0, NULL, (void *) set_buf, buf_dp },
5767 116 { jwin_slider_proc, 196, 104, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, sfx_dp },
5768 //20
5769 116 { jwin_slider_proc, 196, 120, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 3, 0, NULL, (void *) set_pan, pan_dp },
5770 116 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5771 116 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5772 116 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5773 116 { jwin_text_proc, 17, 40, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master MIDI Volume", NULL, NULL },
5774 116 { jwin_text_proc, 17, 56, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master Digi Volume", NULL, NULL },
5775 116 { jwin_text_proc, 17, 72, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Volume", NULL, NULL },
5776 116 { jwin_text_proc, 17, 88, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Buffer", NULL, NULL },
5777 116 { jwin_text_proc, 17, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Volume", NULL, NULL },
5778 116 { jwin_text_proc, 17, 120, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Pan", NULL, NULL },
5779 //30
5780 116 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5781 116 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5782 116 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5783 116 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5784 };
5785
5786 char zc_builddate[80];
5787 char zc_aboutstr[80];
5788
5789 static DIALOG about_dlg[] =
5790 {
5791 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
5792 { jwin_win_proc, 68, 52, 184, 154, 0, 0, 0, D_EXIT, 0, 0, (void *) "About", NULL, NULL },
5793 { jwin_button_proc, 140, 176, 41, 21, vc(14), 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5794 { jwin_ctext_proc, 160, 84, 0, 8, vc(0), vc(11), 0, 0, 0, 0, zc_aboutstr, NULL, NULL },
5795 { jwin_ctext_proc, 160, 92, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5796 { jwin_ctext_proc, 160, 100, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, zc_builddate, NULL, NULL },
5797 { jwin_text_proc, 88, 124, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Coded by:", NULL, NULL },
5798 { jwin_text_proc, 88, 132, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Phantom Menace", NULL, NULL },
5799 { jwin_text_proc, 88, 144, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Produced by:", NULL, NULL },
5800 { jwin_text_proc, 88, 152, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Armageddon Games", NULL, NULL },
5801 { jwin_frame_proc, 80, 117, 160, 50, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5802 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5803 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5804 };
5805
5806
5807 static DIALOG quest_dlg[] =
5808 {
5809 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
5810 { jwin_win_proc, 68, 25, 184, 190, 0, 0, 0, D_EXIT, 0, 0, (void *) "Quest Info", NULL, NULL },
5811 { jwin_edit_proc, 84, 54, 152, 16, 0, 0, 0, D_READONLY, 100, 0, NULL, NULL, NULL },
5812 { jwin_text_proc, 89, 84, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
5813 { jwin_text_proc, 152, 84, 24, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5814 { jwin_text_proc, 89, 94, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Version:", NULL, NULL },
5815 { jwin_text_proc, 160, 94, 64, 8, vc(7), vc(11), 0, 0, 0, 0, header_version_nul_term, NULL, NULL },
5816 { jwin_text_proc, 89, 104, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "ZQ Version:", NULL, NULL },
5817 { jwin_text_proc, 184, 104, 64, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5818 { jwin_text_proc, 84, 126, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Title:", NULL, NULL },
5819 { jwin_textbox_proc, 84, 136, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.title, NULL, NULL },
5820 { jwin_text_proc, 84, 168, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Author:", NULL, NULL },
5821 { jwin_textbox_proc, 84, 178, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.author, NULL, NULL },
5822 { jwin_frame_proc, 84, 79, 152, 38, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5823 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5824 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5825 };
5826
5827 static DIALOG triforce_dlg[] =
5828 {
5829 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
5830 { jwin_win_proc, 72, 64, 177, 105, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Triforce Pieces", NULL, NULL },
5831 // 1
5832 { jwin_check_proc, 129, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "1", NULL, NULL },
5833 { jwin_check_proc, 129, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "2", NULL, NULL },
5834 { jwin_check_proc, 129, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "3", NULL, NULL },
5835 { jwin_check_proc, 129, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "4", NULL, NULL },
5836 { jwin_check_proc, 172, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "5", NULL, NULL },
5837 { jwin_check_proc, 172, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "6", NULL, NULL },
5838 { jwin_check_proc, 172, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "7", NULL, NULL },
5839 { jwin_check_proc, 172, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "8", NULL, NULL },
5840 // 9
5841 { jwin_button_proc, 90, 144, 61, 21, vc(0), vc(11), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
5842 { jwin_button_proc, 170, 144, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5843 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5844 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5845 };
5846
5847 bool zc_getname(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
5848 {
5849 go();
5850 int32_t ret=0;
5851 ret = zc_getname_nogo(prompt,ext,list,def,usefilename);
5852 comeback();
5853 return ret != 0;
5854 }
5855
5856
5857 bool zc_getname_nogo(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
5858 {
5859 if(def!=modulepath)
5860 strcpy(modulepath,def);
5861
5862 if(!usefilename)
5863 {
5864 int32_t i=(int32_t)strlen(modulepath);
5865
5866 while(i>=0 && modulepath[i]!='\\' && modulepath[i]!='/')
5867 modulepath[i--]=0;
5868 }
5869
5870 // int32_t ret = file_select_ex(prompt,modulepath,ext,255,-1,-1);
5871 int32_t ret=0;
5872 int32_t sel=0;
5873
5874 if(list==NULL)
5875 {
5876 ret = jwin_file_select_ex(prompt,modulepath,ext,2048,-1,-1,get_zc_font(font_lfont));
5877 }
5878 else
5879 {
5880 ret = jwin_file_browse_ex(prompt, modulepath, list, &sel, 2048, -1, -1, get_zc_font(font_lfont));
5881 }
5882
5883 return ret!=0;
5884 }
5885
5886 //The Dialogue that loads a ZMOD Module File
5887 int32_t zc_load_zmod_module_file()
5888 {
5889 if ( Playing )
5890 {
5891 jwin_alert("Error","Cannot change module while playing a quest!",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
5892 return -1;
5893 }
5894 if(!zc_getname("Load Module (.zmod)","zmod",NULL,modulepath,false))
5895 return D_CLOSE;
5896
5897 FILE *tempmodule = fopen(modulepath,"r");
5898
5899 if(tempmodule == NULL)
5900 {
5901 jwin_alert("Error","Cannot open specified file!",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
5902 return -1;
5903 }
5904
5905
5906 //Set the module path:
5907 memset(moduledata.module_name, 0, sizeof(moduledata.module_name));
5908 strcpy(moduledata.module_name, modulepath);
5909 al_trace("New Module Path is: %s \n", moduledata.module_name);
5910 zc_set_config("ZCMODULE","current_module",moduledata.module_name);
5911 zcm.init(true); //Load the module values.
5912 moduledata.refresh_title_screen = 1;
5913 // refresh_select_screen = 1;
5914 build_biic_list();
5915 return D_O_K;
5916 }
5917
5918 static DIALOG module_info_dlg[] =
5919 {
5920 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
5921
5922
5923 { jwin_win_proc, 0, 0, 200, 200, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "About Current Module", NULL, NULL },
5924 //1
5925 { jwin_text_proc, 10, 20, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Module:", NULL, NULL },
5926 //2
5927 { jwin_text_proc, 50, 20, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5928 { jwin_text_proc, 10, 30, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Author:", NULL, NULL },
5929 //4
5930 { jwin_text_proc, 50, 30, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5931 { jwin_text_proc, 10, 40, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5932 { jwin_text_proc, 10, 50, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Information:", NULL, NULL },
5933 //7
5934
5935 { jwin_text_proc, 10, 60, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5936 { jwin_text_proc, 10, 70, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5937 { jwin_text_proc, 10, 80, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5938 { jwin_text_proc, 10, 90, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5939 { jwin_text_proc, 10, 100, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5940 { jwin_text_proc, 10, 120, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5941 { jwin_text_proc, 10, 130, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5942 { jwin_text_proc, 10, 140, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5943 { jwin_text_proc, 10, 150, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
5944
5945 { jwin_button_proc, 40, 160, 50, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5946 { jwin_button_proc, 200-40-50, 160, 50, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5947 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5948 };
5949
5950 void about_zcplayer_module(const char *prompt,int32_t initialval)
5951 {
5952
5953 module_info_dlg[0].dp2 = get_zc_font(font_lfont);
5954 if ( moduledata.moduletitle[0] != 0 )
5955 module_info_dlg[2].dp = (char*)moduledata.moduletitle;
5956
5957 if ( moduledata.moduleauthor[0] != 0 )
5958 module_info_dlg[4].dp = (char*)moduledata.moduleauthor;
5959
5960 if ( moduledata.moduleinfo0[0] != 0 )
5961 module_info_dlg[7].dp = (char*)moduledata.moduleinfo0;
5962 if ( moduledata.moduleinfo1[0] != 0 )
5963 module_info_dlg[8].dp = (char*)moduledata.moduleinfo1;
5964 if ( moduledata.moduleinfo2[0] != 0 )
5965 module_info_dlg[9].dp = (char*)moduledata.moduleinfo2;
5966 if ( moduledata.moduleinfo3[0] != 0 )
5967 module_info_dlg[10].dp = (char*)moduledata.moduleinfo3;
5968 if ( moduledata.moduleinfo4[0] != 0 )
5969 module_info_dlg[11].dp = (char*)moduledata.moduleinfo4;
5970
5971 char module_date[255];
5972 memset(module_date, 0, sizeof(module_date));
5973 sprintf(module_date,"Build Date: %s %s, %d at @ %d:%d %s", dayextension(moduledata.modday).c_str(),
5974 (char*)months[moduledata.modmonth], moduledata.modyear, moduledata.modhour, moduledata.modminute, moduledata.moduletimezone);
5975
5976
5977
5978 char module_vers[255];
5979 memset(module_vers, 0, sizeof(module_vers));
5980 sprintf(module_vers, "Version: %d.%d.%d.%d", moduledata.modver_1, moduledata.modver_2, moduledata.modver_3, moduledata.modver_4);
5981
5982
5983 //sprintf(tilecount,"%d",1);
5984
5985 char module_build[255];
5986 memset(module_build, 0, sizeof(module_build));
5987 if ( moduledata.modbeta )
5988 sprintf(module_build,"Module Build: %d, %s: %d", moduledata.modbuild, (moduledata.modbeta<0) ? "Alpha" : "Beta", moduledata.modbeta );
5989 else
5990 sprintf(module_build,"Module Build: %d", moduledata.modbuild);
5991
5992 module_info_dlg[12].dp = (char*)module_date;
5993 module_info_dlg[13].dp = (char*)module_vers;
5994 module_info_dlg[14].dp = (char*)module_build;
5995
5996 large_dialog(module_info_dlg);
5997
5998 int32_t ret = zc_popup_dialog(module_info_dlg,-1);
5999 jwin_center_dialog(module_info_dlg);
6000
6001
6002 }
6003
6004 int32_t onAbout_ZCP_Module()
6005 {
6006 about_zcplayer_module("About Module (.zmod)", 0);
6007 return D_O_K;
6008 }
6009
6010 //New Modules Menu for 2.55+
6011 static MENU zcmodule_menu[] =
6012 {
6013 { (char *)"&Load Module...", zc_load_zmod_module_file, NULL, 0, NULL },
6014 { (char *)"&About Module", onAbout_ZCP_Module, NULL, 0, NULL },
6015
6016 { NULL, NULL, NULL, 0, NULL }
6017 };
6018
6019 int32_t onToggleRecordingNewSaves()
6020 {
6021 if (zc_get_config("zeldadx", "replay_new_saves", false))
6022 {
6023 zc_set_config("zeldadx", "replay_new_saves", false);
6024 }
6025 else
6026 {
6027 zc_set_config("zeldadx", "replay_new_saves", true);
6028 jwin_alert("Recording", "Newly created saves will be recorded and written to a replay file.",
6029 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6030 }
6031 return D_O_K;
6032 }
6033
6034 int32_t onToggleSnapshotAllFrames()
6035 {
6036 replay_set_snapshot_all_frames(!replay_is_snapshot_all_frames());
6037 return D_O_K;
6038 }
6039
6040 int32_t onStopReplayOrRecord()
6041 {
6042 if (replay_is_replaying())
6043 {
6044 replay_quit();
6045 }
6046 else if (replay_get_mode() == ReplayMode::Record)
6047 {
6048 if (!replay_get_meta_bool("test_mode"))
6049 {
6050 jwin_alert("Recording", "You cannot stop recording a save file.",
6051 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6052 return D_CLOSE;
6053 }
6054
6055 if (jwin_alert("Stop Recording",
6056 "Save replay to disk and stop recording?",
6057 "This will stop the recording.",
6058 NULL,
6059 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
6060 return D_CLOSE;
6061
6062 replay_save();
6063 replay_stop();
6064 }
6065 return D_O_K;
6066 }
6067
6068 static int32_t handle_on_load_replay(ReplayMode mode)
6069 {
6070 if (Playing)
6071 {
6072 if (jwin_alert("Replay - Warning!",
6073 "Loading a replay will exit the current game.",
6074 "All unsaved progress will be lost.",
6075 "Do you wish to continue?",
6076 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
6077 return D_CLOSE;
6078 }
6079
6080 std::string mode_string = replay_mode_to_string(mode);
6081 mode_string[0] = std::toupper(mode_string[0]);
6082
6083 std::string line_1 = "Select a replay file to play back.";
6084 std::string line_2 = "You won't be able to save, and it won't effect existing saves.";
6085 std::string line_3 = "You can stop the replay and take over manually any time.";
6086 if (mode == ReplayMode::Update)
6087 {
6088 line_1 = "Select a replay file to update.";
6089 line_2 = "WARNING: be sure to back up the zplay file";
6090 line_3 = "and verify that the updated replay works as expected!";
6091 }
6092
6093 if (jwin_alert(mode_string.c_str(),
6094 line_1.c_str(),
6095 line_2.c_str(),
6096 line_3.c_str(),
6097 "OK","Nevermind",13,27,get_zc_font(font_lfont)) == 1)
6098 {
6099 char replay_path[2048];
6100 strcpy(replay_path, "replays/");
6101 if (jwin_file_select_ex(
6102 fmt::format("Load Replay ({})", REPLAY_EXTENSION).c_str(),
6103 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, get_zc_font(font_lfont)) == 0)
6104 return D_CLOSE;
6105
6106 replay_quit();
6107 load_replay_file_deferred(mode, replay_path);
6108 Quit = qRESET;
6109 return D_CLOSE;
6110 }
6111 return D_O_K;
6112 }
6113
6114 int32_t onLoadReplay()
6115 {
6116 return handle_on_load_replay(ReplayMode::Replay);
6117 }
6118
6119 int32_t onLoadReplayAssert()
6120 {
6121 return handle_on_load_replay(ReplayMode::Assert);
6122 }
6123
6124 int32_t onLoadReplayUpdate()
6125 {
6126 return handle_on_load_replay(ReplayMode::Update);
6127 }
6128
6129 int32_t onSaveReplay()
6130 {
6131 if (replay_get_mode() == ReplayMode::Record)
6132 {
6133 if (!replay_get_meta_bool("test_mode"))
6134 {
6135 if (jwin_alert("Save Replay",
6136 "This will save a copy of the replay up to this point.",
6137 "The official replay file will be untouched.",
6138 "Do you wish to continue?",
6139 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
6140 return D_CLOSE;
6141
6142 char replay_path[2048];
6143 strcpy(replay_path, replay_get_replay_path().string().c_str());
6144 if (jwin_file_select_ex(
6145 fmt::format("Save Replay ({})", REPLAY_EXTENSION).c_str(),
6146 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, get_zc_font(font_lfont)) == 0)
6147 return D_CLOSE;
6148
6149 if (fileexists(replay_path))
6150 {
6151 jwin_alert("Save Replay", "You cannot overwrite an existing file.",
6152 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6153 return D_CLOSE;
6154 }
6155
6156 replay_save(replay_path);
6157 }
6158 else
6159 {
6160 replay_save();
6161 }
6162 }
6163 return D_O_K;
6164 }
6165
6166 static MENU replay_menu[] =
6167 {
6168 { (char *)"Record new saves", onToggleRecordingNewSaves, NULL, 0, NULL },
6169 { (char *)"Stop replay", onStopReplayOrRecord, NULL, 0, NULL },
6170 { (char *)"Load replay", onLoadReplay, NULL, 0, NULL },
6171 { (char *)"Load replay (assert)", onLoadReplayAssert, NULL, 0, NULL },
6172 { (char *)"Load replay (update)", onLoadReplayUpdate, NULL, 0, NULL },
6173 { (char *)"Save replay", onSaveReplay, NULL, 0, NULL },
6174 { (char *)"Enable snapshot all frames", onToggleSnapshotAllFrames,NULL, 0, NULL },
6175
6176 { NULL, NULL, NULL, 0, NULL }
6177 };
6178
6179 static DIALOG credits_dlg[] =
6180 {
6181 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6182 { jwin_win_proc, 40, 38, 241, 173, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "ZQuest Classic Credits", NULL, NULL },
6183 { jwin_frame_proc, 47, 65, 227, 115, vc(15), vc(1), 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
6184 { d_bitmap_proc, 49, 67, 222, 110, vc(15), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
6185 { jwin_button_proc, 140, 184, 41, 21, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6186 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6187 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6188 };
6189
6190 116 static ListData dmap_list(dmaplist, &font);
6191
6192 static DIALOG goto_dlg[] =
6193 {
6194 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6195 { jwin_win_proc, 48, 25, 205, 100, 0, 0, 0, D_EXIT, 0, 0, (void *) "Goto Location", NULL, NULL },
6196 { jwin_button_proc, 90, 176-78, 61, 21, vc(14), 0, 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6197 { jwin_button_proc, 170, 176-78, 61, 21, vc(14), 0, 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6198 { jwin_text_proc, 55, 129-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "DMap:", NULL, NULL },
6199 { jwin_droplist_proc, 88, 126-75, 160, 16, 0, 0, 0, 0, 0, 0, (void *) &dmap_list, NULL, NULL },
6200 { jwin_text_proc, 55, 149-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Screen:", NULL, NULL },
6201 { jwin_edit_proc, 132, 146-75, 91, 16, 0, 0, 0, 0, 2, 0, NULL, NULL, NULL },
6202 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6203 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6204 };
6205
6206 int32_t onGoTo()
6207 {
6208 bool music = false;
6209 music = music;
6210 sprintf(cheat_goto_screen_str,"%X",cheat_goto_screen);
6211
6212 goto_dlg[0].dp2=get_zc_font(font_lfont);
6213 goto_dlg[4].d2=cheat_goto_dmap;
6214 goto_dlg[6].dp=cheat_goto_screen_str;
6215
6216 clear_keybuf();
6217
6218 large_dialog(goto_dlg);
6219
6220 if(zc_popup_dialog(goto_dlg,4)==1)
6221 {
6222 // dmap, screen
6223 cheats_enqueue(Cheat::GoTo, goto_dlg[4].d2, zc_min(zc_xtoi(cheat_goto_screen_str),0x7F));
6224 };
6225
6226 return D_O_K;
6227 }
6228
6229 int32_t onGoToComplete()
6230 {
6231 if(!Playing)
6232 {
6233 return D_O_K;
6234 }
6235
6236 enter_sys_pal();
6237 music_pause();
6238 pause_all_sfx();
6239 onGoTo();
6240 eat_buttons();
6241
6242 zc_readrawkey(KEY_ESC);
6243
6244 exit_sys_pal();
6245 music_resume();
6246 resume_all_sfx();
6247 return D_O_K;
6248 }
6249
6250 int32_t onCredits()
6251 {
6252 go();
6253
6254 BITMAP *win = create_bitmap_ex(8,222,110);
6255
6256 if(!win)
6257 return D_O_K;
6258
6259 int32_t c=0;
6260 int32_t l=0;
6261 int32_t ol=-1;
6262 RLE_SPRITE *rle = (RLE_SPRITE*)(datafile[RLE_CREDITS].dat);
6263 RGB *pal = (RGB*)(datafile[PAL_CREDITS].dat);
6264 PALETTE tmppal;
6265
6266 rti_gui.transparency_index = 1;
6267
6268 clear_to_color(win, rti_gui.transparency_index);
6269 draw_rle_sprite(win,rle,0,0);
6270 credits_dlg[0].dp2=get_zc_font(font_lfont);
6271 credits_dlg[1].fg = jwin_pal[jcDISABLED_FG];
6272 credits_dlg[2].dp = win;
6273
6274 zc_set_palette_range(black_palette,0,127,false);
6275
6276 DIALOG_PLAYER *p = init_dialog(credits_dlg,3);
6277
6278 BITMAP* old_screen = screen;
6279 BITMAP* gui_bmp = zc_get_gui_bmp();
6280 ASSERT(gui_bmp);
6281 clear_to_color(gui_bmp, rti_gui.transparency_index);
6282 screen = gui_bmp;
6283
6284 while(update_dialog(p))
6285 {
6286 throttleFPS();
6287 ++c;
6288 l = zc_max((c>>1)-30,0);
6289
6290 if(l > rle->h)
6291 l = c = 0;
6292
6293 if(l > rle->h - 112)
6294 l = rle->h - 112;
6295
6296 clear_bitmap(win);
6297 draw_rle_sprite(win,rle,0,0-l);
6298
6299 if(c<=64)
6300 fade_interpolate(black_palette,pal,tmppal,c,0,127);
6301
6302 zc_set_palette_range(tmppal,0,127,false);
6303
6304 if(l!=ol)
6305 {
6306 d_bitmap_proc(MSG_DRAW,credits_dlg+2,0);
6307 SCRFIX();
6308 ol=l;
6309 }
6310
6311 update_hw_screen();
6312 }
6313
6314 screen = old_screen;
6315 system_pal(true);
6316 sys_mouse();
6317
6318 shutdown_dialog(p);
6319 destroy_bitmap(win);
6320 //comeback();
6321
6322 rti_gui.transparency_index = 0;
6323 clear_to_color(gui_bmp, rti_gui.transparency_index);
6324
6325 return D_O_K;
6326 }
6327
6328 const char *midilist(int32_t index, int32_t *list_size)
6329 {
6330 if(index<0)
6331 {
6332 *list_size=0;
6333
6334 for(int32_t i=0; i<MAXMIDIS; i++)
6335 if(tunes[i].data)
6336 ++(*list_size);
6337
6338 return NULL;
6339 }
6340
6341 int32_t i=0,m=0;
6342
6343 while(m<=index && i<=MAXMIDIS)
6344 {
6345 if(tunes[i].data)
6346 ++m;
6347
6348 ++i;
6349 }
6350
6351 --i;
6352
6353 if(i==MAXMIDIS && m<index)
6354 return "(null)";
6355
6356 return tunes[i].title;
6357 }
6358
6359 /* ------- MIDI info stuff -------- */
6360
6361 char *text;
6362 midi_info *zmi;
6363 bool dialog_running;
6364 bool listening;
6365
6366 void get_info(int32_t index);
6367
6368 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c)
6369 {
6370 int32_t d2 = d->d2;
6371 int32_t ret = jwin_droplist_proc(msg,d,c);
6372
6373 if(d2!=d->d2)
6374 {
6375 get_info(d->d2);
6376 }
6377
6378 return ret;
6379 }
6380
6381 int32_t d_listen_proc(int32_t msg,DIALOG *d,int32_t c)
6382 {
6383 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6384
6385 int32_t ret = jwin_button_proc(msg,d,c);
6386
6387 if(ret == D_CLOSE)
6388 {
6389 // get current midi index
6390 int32_t index = (d+(d->d1))->d2;
6391 int32_t i=0, m=0;
6392
6393 while(m<=index && i<=MAXMIDIS)
6394 {
6395 if(tunes[i].data)
6396 ++m;
6397
6398 ++i;
6399 }
6400
6401 --i;
6402 jukebox(i);
6403 listening = true;
6404 ret = D_O_K;
6405 }
6406
6407 return ret;
6408 }
6409
6410 int32_t d_savemidi_proc(int32_t msg,DIALOG *d,int32_t c)
6411 {
6412 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6413
6414 int32_t ret = jwin_button_proc(msg,d,c);
6415
6416 if(ret == D_CLOSE)
6417 {
6418 // get current midi index
6419 int32_t index = (d+(d->d1))->d2;
6420 int32_t i=0, m=0;
6421
6422 while(m<=index && i<=MAXMIDIS)
6423 {
6424 if(tunes[i].data)
6425 ++m;
6426
6427 ++i;
6428 }
6429
6430 --i;
6431
6432 // get file name
6433
6434 int32_t sel=0;
6435 //struct ffblk f;
6436 char title[40] = "Save MIDI: ";
6437 char fname[2048];
6438 memset(fname,0,2048);
6439 static EXT_LIST list[] =
6440 {
6441 { (char *)"MIDI files (*.mid)", (char *)"mid" },
6442 { (char *)"HTML files (*.html, *.html)", (char *)"htm html" },
6443 { NULL, NULL }
6444 };
6445
6446 strcpy(title+11, tunes[i].title);
6447 title[39] = '\0';
6448
6449 if(jwin_file_browse_ex(title, fname, list, &sel, 2048, -1, -1, get_zc_font(font_lfont))==0)
6450 goto done;
6451
6452 if(exists(fname))
6453 {
6454 if(jwin_alert(title, fname, "already exists.", "Overwrite it?", "&Yes","&No",'y','n',get_zc_font(font_lfont))==2)
6455 goto done;
6456 }
6457
6458 // save midi i
6459
6460 if(save_midi(fname, (MIDI*)tunes[i].data) != 0)
6461 jwin_alert(title, "Error saving MIDI to", fname, NULL, "Darn", NULL,13,27,get_zc_font(font_lfont));
6462
6463 done:
6464 chop_path(fname);
6465 ret = D_REDRAW;
6466 }
6467
6468 return ret;
6469 }
6470
6471 116 static ListData midi_list(midilist, &font);
6472
6473 static DIALOG midi_dlg[] =
6474 {
6475 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6476 { jwin_win_proc, 8, 28, 304, 184, 0, 0, 0, D_EXIT, 0, 0, (void *) "MIDI Info", NULL, NULL },
6477 { jwin_text_proc, 32, 60, 40, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Tune:", NULL, NULL },
6478 { d_midilist_proc, 80, 56, 192, 16, 0, 0, 0, 0, 0, 0, (void *) &midi_list, NULL, NULL },
6479 { jwin_textbox_proc, 15, 80, 290, 96, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6480 { d_listen_proc, 24, 183, 72, 21, 0, 0, 'l', D_EXIT, -2, 0, (void *) "&Listen", NULL, NULL },
6481 { d_savemidi_proc, 108, 183, 72, 21, 0, 0, 's', D_EXIT, -3, 0, (void *) "&Save", NULL, NULL },
6482 { jwin_button_proc, 236, 183, 61, 21, 0, 0, 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6483 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6484 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6485 };
6486
6487 void get_info(int32_t index)
6488 {
6489 int32_t i=0, m=0;
6490
6491 while(m<=index && i<=MAXMIDIS)
6492 {
6493 if(tunes[i].data)
6494 ++m;
6495
6496 ++i;
6497 }
6498
6499 --i;
6500
6501 if(i==MAXMIDIS && m<index)
6502 strcpy(text,"(null)");
6503 else
6504 {
6505 get_midi_info((MIDI*)tunes[i].data,zmi);
6506 get_midi_text((MIDI*)tunes[i].data,zmi,text);
6507 }
6508
6509 midi_dlg[0].dp2=get_zc_font(font_lfont);
6510 midi_dlg[3].dp = text;
6511 midi_dlg[3].d1 = midi_dlg[3].d2 = 0;
6512 midi_dlg[5].flags = (tunes[i].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6513
6514 if(dialog_running)
6515 {
6516 jwin_textbox_proc(MSG_DRAW,midi_dlg+3,0);
6517 d_savemidi_proc(MSG_DRAW,midi_dlg+5,0);
6518 }
6519 }
6520
6521 int32_t onMIDICredits()
6522 {
6523 text = (char*)malloc(4096);
6524 zmi = (midi_info*)malloc(sizeof(midi_info));
6525
6526 if(!text || !zmi)
6527 {
6528 jwin_alert(NULL,"Not enough memory",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6529 return D_O_K;
6530 }
6531
6532 bool do_pause_midi = midi_pos >= 0 && currmidi;
6533 auto restore_midi = currmidi;
6534 if(do_pause_midi)
6535 {
6536 paused_midi_pos = midi_pos;
6537 stop_midi();
6538 midi_suspended = midissuspHALTED;
6539 }
6540
6541 midi_dlg[0].dp2=get_zc_font(font_lfont);
6542 midi_dlg[2].d1 = 0;
6543 midi_dlg[2].d2 = 0;
6544 midi_dlg[4].flags = D_EXIT;
6545 midi_dlg[5].flags = (tunes[midi_dlg[2].d1].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6546
6547 listening = false;
6548 dialog_running=false;
6549 get_info(0);
6550
6551 dialog_running=true;
6552
6553 large_dialog(midi_dlg);
6554
6555 zc_popup_dialog(midi_dlg,0);
6556 dialog_running=false;
6557
6558 if(listening)
6559 music_stop();
6560
6561 if(do_pause_midi)
6562 {
6563 // TODO: this probably doesn't resume midis nicely when scrolling (or in some other inner-gameloop).
6564 midi_suspended = midissuspRESUME;
6565 currmidi = restore_midi;
6566 midi_pos = paused_midi_pos;
6567 }
6568
6569 if(text) free(text);
6570 if(zmi) free(zmi);
6571 return D_O_K;
6572 }
6573
6574 int32_t onAbout()
6575 {
6576 char buf1[80]={0};
6577 std::ostringstream oss;
6578 sprintf(buf1,"%s (%s), Version: %s", ZC_PLAYER_NAME,PROJECT_NAME,ZC_PLAYER_V);
6579 oss << buf1 << '\n';
6580 sprintf(buf1, "%s, Build %d", ALPHA_VER_STR, VERSION_BUILD);
6581 oss << buf1 << '\n';
6582 sprintf(buf1,"Build Date: %s %s, %d at @ %s %s", dayextension(BUILDTM_DAY).c_str(), (char*)months[BUILDTM_MONTH], BUILDTM_YEAR, __TIME__, __TIMEZONE__);
6583 oss << buf1 << '\n';
6584 sprintf(buf1, "Built By: %s", DEV_SIGNOFF);
6585 oss << buf1 << '\n';
6586 sprintf(buf1, "Tag: %s", getReleaseTag());
6587 oss << buf1 << '\n';
6588
6589 InfoDialog("About ZC", oss.str()).show();
6590 return D_O_K;
6591 }
6592
6593 int32_t onQuest()
6594 {
6595 char fname[100];
6596 strcpy(fname, get_filename(qstpath));
6597 quest_dlg[0].dp2=get_zc_font(font_lfont);
6598 quest_dlg[1].dp = fname;
6599
6600 if(QHeader.quest_number==0)
6601 sprintf(str_a,"Custom");
6602 else
6603 sprintf(str_a,"%d",QHeader.quest_number);
6604
6605 sprintf(str_s,"%s",VerStr(QHeader.zelda_version));
6606
6607 quest_dlg[11].d1 = quest_dlg[9].d1 = 0;
6608 quest_dlg[11].d2 = quest_dlg[9].d2 = 0;
6609
6610 large_dialog(quest_dlg);
6611
6612 zc_popup_dialog(quest_dlg, 0);
6613 return D_O_K;
6614 }
6615
6616 void call_vidmode_dlg();
6617 int32_t onVidMode()
6618 {
6619 call_vidmode_dlg();
6620 return D_O_K;
6621 }
6622
6623 #define addToHash(c,b,h) if(h->find(c ## key) == h->end()) \
6624 {(*h)[c ## key]=true;} else { if ( c ## key != 0 ) b = false;}
6625 //Added an extra statement, so that if the key is cleared to 0, the cleared
6626 //keybinding status need not be unique. -Z ( 1st April, 2019 )
6627
6628 void load_ukeys(int32_t* arr)
6629 {
6630 arr[ukey_a] = Akey;
6631 arr[ukey_b] = Bkey;
6632 arr[ukey_s] = Skey;
6633 arr[ukey_l] = Lkey;
6634 arr[ukey_r] = Rkey;
6635 arr[ukey_p] = Pkey;
6636 arr[ukey_ex1] = Exkey1;
6637 arr[ukey_ex2] = Exkey2;
6638 arr[ukey_ex3] = Exkey3;
6639 arr[ukey_ex4] = Exkey4;
6640 arr[ukey_du] = DUkey;
6641 arr[ukey_dd] = DDkey;
6642 arr[ukey_dl] = DLkey;
6643 arr[ukey_dr] = DRkey;
6644 arr[ukey_mod1a] = cheat_modifier_keys[0];
6645 arr[ukey_mod1b] = cheat_modifier_keys[1];
6646 arr[ukey_mod2a] = cheat_modifier_keys[2];
6647 arr[ukey_mod2b] = cheat_modifier_keys[3];
6648 };
6649
6650 static const char* ukey_names[] = {
6651 "A", "B", "Start", "L", "R", "Map",
6652 "Ex1", "Ex2", "Ex3", "Ex4", "Up", "Down",
6653 "Left", "Right", "Cheat Mod L1", "Cheat Mod L2",
6654 "Cheat Mod R1", "Cheat Mod R2",
6655 };
6656 std::string get_ukey_name(int32_t k)
6657 {
6658 if (k < num_ukey) return ukey_names[k];
6659 return "";
6660 }
6661
6662 int32_t onKeyboard()
6663 {
6664 int32_t a = Akey;
6665 int32_t b = Bkey;
6666 int32_t s = Skey;
6667 int32_t l = Lkey;
6668 int32_t r = Rkey;
6669 int32_t p = Pkey;
6670 int32_t ex1 = Exkey1;
6671 int32_t ex2 = Exkey2;
6672 int32_t ex3 = Exkey3;
6673 int32_t ex4 = Exkey4;
6674 int32_t du = DUkey;
6675 int32_t dd = DDkey;
6676 int32_t dl = DLkey;
6677 int32_t dr = DRkey;
6678 int32_t mod1a = cheat_modifier_keys[0];
6679 int32_t mod1b = cheat_modifier_keys[1];
6680 int32_t mod2a = cheat_modifier_keys[2];
6681 int32_t mod2b = cheat_modifier_keys[3];
6682 bool done=false;
6683 int32_t ret;
6684
6685 keyboard_control_dlg[0].dp2=get_zc_font(font_lfont);
6686
6687 large_dialog(keyboard_control_dlg);
6688
6689 while(!done)
6690 {
6691 ret = zc_popup_dialog(keyboard_control_dlg,3);
6692
6693 if(ret==3) // OK
6694 {
6695 int32_t ukeys[num_ukey];
6696 load_ukeys(ukeys);
6697 std::vector<std::string> uniqueError;
6698 for(int32_t q = 0; q < num_ukey; ++q)
6699 {
6700 for(int32_t p = q+1; p < num_ukey; ++p)
6701 {
6702 if(ukeys[q] == ukeys[p] && ukeys[q] != 0)
6703 {
6704 char buf[64];
6705 sprintf(buf, "'%s' conflicts with '%s'", get_ukey_name(q).c_str(), get_ukey_name(p).c_str());
6706 std::string str(buf);
6707 uniqueError.push_back(str);
6708 }
6709 }
6710 }
6711 if(uniqueError.size() == 0)
6712 {
6713 done = true;
6714 save_control_configs(true);
6715 }
6716 else
6717 {
6718 box_start(1, "Duplicate Keys", get_zc_font(font_lfont), get_zc_font(font_sfont), false, keyboard_control_dlg[0].w,keyboard_control_dlg[0].h, 2);
6719 box_out("Cannot have duplicate keybinds!"); box_eol();
6720 for(std::vector<std::string>::iterator it = uniqueError.begin();
6721 it != uniqueError.end(); ++it)
6722 {
6723 box_out((*it).c_str()); box_eol();
6724 }
6725 box_end(true);
6726 }
6727 }
6728 else // Cancel
6729 {
6730 Akey = a;
6731 Bkey = b;
6732 Skey = s;
6733 Lkey = l;
6734 Rkey = r;
6735 Pkey = p;
6736 Exkey1 = ex1;
6737 Exkey2 = ex2;
6738 Exkey3 = ex3;
6739 Exkey4 = ex4;
6740 DUkey = du;
6741 DDkey = dd;
6742 DLkey = dl;
6743 DRkey = dr;
6744 cheat_modifier_keys[0] = mod1a;
6745 cheat_modifier_keys[1] = mod1b;
6746 cheat_modifier_keys[2] = mod2a;
6747 cheat_modifier_keys[3] = mod2b;
6748
6749 done=true;
6750 }
6751
6752 rest(1);
6753 }
6754
6755 return D_O_K;
6756 }
6757
6758 int32_t onGamepad()
6759 {
6760 int32_t a = Abtn;
6761 int32_t b = Bbtn;
6762 int32_t s = Sbtn;
6763 int32_t l = Lbtn;
6764 int32_t r = Rbtn;
6765 int32_t m = Mbtn;
6766 int32_t p = Pbtn;
6767 int32_t ex1 = Exbtn1;
6768 int32_t ex2 = Exbtn2;
6769 int32_t ex3 = Exbtn3;
6770 int32_t ex4 = Exbtn4;
6771 int32_t up = DUbtn;
6772 int32_t down = DDbtn;
6773 int32_t left = DLbtn;
6774 int32_t right = DRbtn;
6775
6776 gamepad_dlg[0].dp2=get_zc_font(font_lfont);
6777 if(analog_movement)
6778 gamepad_dlg[56].flags|=D_SELECTED;
6779 else
6780 gamepad_dlg[56].flags&=~D_SELECTED;
6781
6782 large_dialog(gamepad_dlg);
6783
6784 int32_t ret = zc_popup_dialog(gamepad_dlg,4);
6785
6786 if(ret == 4) //OK
6787 {
6788 analog_movement = gamepad_dlg[56].flags&D_SELECTED;
6789 save_control_configs(false);
6790 }
6791 else //Cancel
6792 {
6793 Abtn = a;
6794 Bbtn = b;
6795 Sbtn = s;
6796 Lbtn = l;
6797 Rbtn = r;
6798 Mbtn = m;
6799 Pbtn = p;
6800 Exbtn1 = ex1;
6801 Exbtn2 = ex2;
6802 Exbtn3 = ex3;
6803 Exbtn4 = ex4;
6804 DUbtn = up;
6805 DDbtn = down;
6806 DLbtn = left;
6807 DRbtn = right;
6808 }
6809
6810 return D_O_K;
6811 }
6812
6813 int32_t onCheatKeys()
6814 {
6815 int32_t oldcheats[Cheat::Last][2];
6816 memcpy(oldcheats, cheatkeys, sizeof(cheatkeys));
6817
6818 bool done=false;
6819
6820 while(!done)
6821 {
6822 bool confirm = false;
6823 CheatKeysDialog(&confirm).show();
6824 if(confirm) // OK
6825 {
6826 std::vector<std::string> uniqueError;
6827 char buf[512];
6828 for(size_t q = 1; q < Cheat::Last; ++q)
6829 {
6830 if(cheatkeys[q][1] && !cheatkeys[q][0])
6831 {
6832 cheatkeys[q][0] = cheatkeys[q][1];
6833 cheatkeys[q][1] = 0;
6834 }
6835 }
6836 for(size_t q = 1; q < Cheat::Last; ++q)
6837 {
6838 if(!bindable_cheat((Cheat)q)) continue;
6839 for(size_t p = q+1; p < Cheat::Last; ++p)
6840 {
6841 if(!bindable_cheat((Cheat)p)) continue;
6842 for(size_t q2 = 0; q2 <= 1; ++q2)
6843 for(size_t p2 = 0; p2 <= 1; ++p2)
6844 {
6845 if(cheatkeys[q][q2] == cheatkeys[p][p2] && cheatkeys[q][q2] != 0)
6846 {
6847 uniqueError.push_back(fmt::format("'{}' ({}) conflicts with '{}' ({}) - both '{}'",
6848 cheat_to_string((Cheat)q), q2?"Alt":"Main",
6849 cheat_to_string((Cheat)p), p2?"Alt":"Main",
6850 get_keystr(cheatkeys[q][q2])));
6851 }
6852 }
6853 }
6854 }
6855 if(uniqueError.size() == 0)
6856 {
6857 done = true;
6858 save_cheatkeys();
6859 }
6860 else
6861 {
6862 box_start(1, "Duplicate Keys", get_zc_font(font_lfont), get_zc_font(font_sfont), false, 500,400, 2);
6863 box_out("Cannot have duplicate keybinds!"); box_eol();
6864 for(std::vector<std::string>::iterator it = uniqueError.begin();
6865 it != uniqueError.end(); ++it)
6866 {
6867 box_out((*it).c_str()); box_eol();
6868 }
6869 box_end(true);
6870 }
6871 }
6872 else // Cancel
6873 {
6874 memcpy(cheatkeys, oldcheats, sizeof(cheatkeys));
6875 done=true;
6876 }
6877 rest(1);
6878 }
6879
6880 return D_O_K;
6881 }
6882
6883 int32_t onSound()
6884 {
6885 if (get_qr(qr_OLD_SCRIPT_VOLUME))
6886 {
6887 if (FFCore.coreflags & FFCORE_SCRIPTED_MIDI_VOLUME)
6888 {
6889 master_volume(-1, ((int32_t)FFCore.usr_midi_volume));
6890 }
6891 if (FFCore.coreflags & FFCORE_SCRIPTED_DIGI_VOLUME)
6892 {
6893 master_volume((int32_t)(FFCore.usr_digi_volume), 1);
6894 }
6895 if (FFCore.coreflags & FFCORE_SCRIPTED_MUSIC_VOLUME)
6896 {
6897 emusic_volume = (int32_t)FFCore.usr_music_volume;
6898 }
6899 if (FFCore.coreflags & FFCORE_SCRIPTED_SFX_VOLUME)
6900 {
6901 sfx_volume = (int32_t)FFCore.usr_sfx_volume;
6902 }
6903 }
6904 if ( FFCore.coreflags&FFCORE_SCRIPTED_PANSTYLE )
6905 {
6906 pan_style = (int32_t)FFCore.usr_panstyle;
6907 }
6908
6909 int32_t m = midi_volume;
6910 int32_t d = digi_volume;
6911 int32_t e = emusic_volume;
6912 int32_t b = zcmusic_bufsz;
6913 int32_t s = sfx_volume;
6914 int32_t p = pan_style;
6915 pan_style = vbound(pan_style,0,3);
6916
6917 sound_dlg[0].dp2=get_zc_font(font_lfont);
6918
6919 large_dialog(sound_dlg);
6920
6921 midi_dp[1] = sound_dlg[6].x;
6922 midi_dp[2] = sound_dlg[6].y;
6923 digi_dp[1] = sound_dlg[7].x;
6924 digi_dp[2] = sound_dlg[7].y;
6925 emus_dp[1] = sound_dlg[8].x;
6926 emus_dp[2] = sound_dlg[8].y;
6927 buf_dp[1] = sound_dlg[9].x;
6928 buf_dp[2] = sound_dlg[9].y;
6929 sfx_dp[1] = sound_dlg[10].x;
6930 sfx_dp[2] = sound_dlg[10].y;
6931 pan_dp[1] = sound_dlg[11].x;
6932 pan_dp[2] = sound_dlg[11].y;
6933 sound_dlg[15].d2 = (midi_volume==255) ? 32 : midi_volume>>3;
6934 sound_dlg[16].d2 = (digi_volume==255) ? 32 : digi_volume>>3;
6935 sound_dlg[17].d2 = (emusic_volume==255) ? 32 : emusic_volume>>3;
6936 sound_dlg[18].d2 = zcmusic_bufsz;
6937 sound_dlg[19].d2 = (sfx_volume==255) ? 32 : sfx_volume>>3;
6938 sound_dlg[20].d2 = pan_style;
6939
6940 int32_t ret = zc_popup_dialog(sound_dlg,1);
6941
6942 if(ret==2)
6943 {
6944 master_volume(digi_volume,midi_volume);
6945 if (zcmusic)
6946 zcmusic_set_volume(zcmusic, emusic_volume);
6947
6948 int32_t temp_volume = sfx_volume;
6949 if (!get_qr(qr_OLD_SCRIPT_VOLUME))
6950 temp_volume = (sfx_volume * FFCore.usr_sfx_volume) / 10000 / 100;
6951 for(int32_t i=0; i<WAV_COUNT; ++i)
6952 {
6953 //allegro assertion fails when passing in -1 as voice -DD
6954 if(sfx_voice[i] > 0)
6955 voice_set_volume(sfx_voice[i], temp_volume);
6956 }
6957 zc_set_config(sfx_sect,"digi",digi_volume);
6958 zc_set_config(sfx_sect,"midi",midi_volume);
6959 zc_set_config(sfx_sect,"sfx",sfx_volume);
6960 zc_set_config(sfx_sect,"emusic",emusic_volume);
6961 zc_set_config(sfx_sect,"pan",pan_style);
6962 zc_set_config(sfx_sect,"zcmusic_bufsz",zcmusic_bufsz);
6963 }
6964 else
6965 {
6966 midi_volume = m;
6967 digi_volume = d;
6968 emusic_volume = e;
6969 zcmusic_bufsz = b;
6970 sfx_volume = s;
6971 pan_style = p;
6972 }
6973
6974 return D_O_K;
6975 }
6976
6977 int32_t queding(char const* s1, char const* s2, char const* s3)
6978 {
6979 return jwin_alert(ZC_str,s1,s2,s3,"&Yes","&No",'y','n',get_zc_font(font_lfont));
6980 }
6981
6982 int32_t onQuit()
6983 {
6984 if(Playing)
6985 {
6986 int32_t ret=0;
6987
6988 if(get_qr(qr_NOCONTINUE))
6989 {
6990 if(standalone_mode)
6991 {
6992 ret=queding("End current game?",
6993 "The continue screen is disabled; the game",
6994 "will be reloaded from the last save.");
6995 }
6996 else
6997 {
6998 ret=queding("End current game?",
6999 "The continue screen is disabled. You will",
7000 "be returned to the file select screen.");
7001 }
7002 }
7003 else
7004 ret=queding("End current game?",NULL,NULL);
7005
7006 if(ret==1)
7007 {
7008 disableClickToFreeze=false;
7009 Quit=qQUIT;
7010
7011 // Trying to evade a door repair charge?
7012 if(repaircharge)
7013 {
7014 game->change_drupy(-repaircharge);
7015 repaircharge=0;
7016 }
7017
7018 return D_CLOSE;
7019 }
7020 }
7021
7022 return D_O_K;
7023 }
7024
7025 int32_t onTryQuitMenu()
7026 {
7027 return onTryQuit(true);
7028 }
7029
7030 int32_t onTryQuit(bool inMenu)
7031 {
7032 if(Playing && !(GameFlags & GAMEFLAG_NO_F6))
7033 {
7034 if(active_cutscene.can_f6())
7035 {
7036 if(get_qr(qr_OLD_F6))
7037 {
7038 if(inMenu) onQuit();
7039 else /*if(!get_qr(qr_NOCONTINUE))*/ f_Quit(qQUIT);
7040 }
7041 else
7042 {
7043 disableClickToFreeze=false;
7044 GameFlags |= GAMEFLAG_TRYQUIT;
7045 }
7046 return D_CLOSE;
7047 }
7048 else active_cutscene.error();
7049 }
7050
7051 return D_O_K;
7052 }
7053
7054 int32_t onReset()
7055 {
7056 if(queding(" Reset system? ",NULL,NULL)==1)
7057 {
7058 disableClickToFreeze=false;
7059 Quit=qRESET;
7060 replay_quit();
7061 return D_CLOSE;
7062 }
7063
7064 return D_O_K;
7065 }
7066
7067 int32_t onExit()
7068 {
7069 if(queding(" Quit ZQuest Classic? ",NULL,NULL)==1)
7070 {
7071 Quit=qEXIT;
7072 return D_CLOSE;
7073 }
7074
7075 return D_O_K;
7076 }
7077
7078 int32_t onTitle_NES()
7079 {
7080 title_version=0;
7081 zc_set_config(cfg_sect,"title",title_version);
7082 return D_O_K;
7083 }
7084 int32_t onTitle_DX()
7085 {
7086 title_version=1;
7087 zc_set_config(cfg_sect,"title",title_version);
7088 return D_O_K;
7089 }
7090 int32_t onTitle_25()
7091 {
7092 title_version=2;
7093 zc_set_config(cfg_sect,"title",title_version);
7094 return D_O_K;
7095 }
7096
7097 int32_t onDebug()
7098 {
7099 if(debug_enabled)
7100 set_debug(!get_debug());
7101 return D_O_K;
7102 }
7103
7104 int32_t onHeartBeep()
7105 {
7106 heart_beep=!heart_beep;
7107 zc_set_config(cfg_sect,"heart_beep",heart_beep);
7108 return D_O_K;
7109 }
7110
7111 int32_t onSaveIndicator()
7112 {
7113 use_save_indicator = use_save_indicator ? 0 : 1;
7114 zc_set_config(cfg_sect,"save_indicator",use_save_indicator);
7115 return D_O_K;
7116 }
7117
7118 int32_t onEpilepsy()
7119 {
7120 if(jwin_alert3(
7121 "Epilepsy Flash Reduction",
7122 "Enabling this will reduce the intensity of flashing and screen wave effects.",
7123 "Disabling this will restore standard flash and wavy behaviour.",
7124 "Proceed?",
7125 "&Yes",
7126 "&No",
7127 NULL,
7128 'y',
7129 'n',
7130 0,
7131 get_zc_font(font_lfont)) == 1)
7132 {
7133 epilepsyFlashReduction = epilepsyFlashReduction ? 0 : 1;
7134 zc_set_config("zeldadx","checked_epilepsy",1);
7135 zc_set_config(cfg_sect,"epilepsy_flash_reduction",epilepsyFlashReduction);
7136 }
7137 return D_O_K;
7138 }
7139
7140 int32_t onTriforce()
7141 {
7142 for(int32_t i=0; i<MAXINITTABS; ++i)
7143 {
7144 init_tabs[i].flags&=~D_SELECTED;
7145 }
7146
7147 init_tabs[3].flags=D_SELECTED;
7148 return onCheatConsole();
7149 /*triforce_dlg[0].dp2=get_zc_font(font_lfont);
7150 for(int32_t i=1; i<=8; i++)
7151 triforce_dlg[i].flags = (game->lvlitems[i] & liTRIFORCE) ? D_SELECTED : 0;
7152
7153 if(zc_popup_dialog (triforce_dlg,-1)==9)
7154 {
7155 for(int32_t i=1; i<=8; i++)
7156 {
7157 game->lvlitems[i] &= ~liTRIFORCE;
7158 game->lvlitems[i] |= (triforce_dlg[i].flags & D_SELECTED) ? liTRIFORCE : 0;
7159 }
7160 }
7161 return D_O_K;*/
7162 }
7163
7164 bool rc = false;
7165 /*
7166 int32_t onEquipment()
7167 {
7168 for (int32_t i=0; i<MAXINITTABS; ++i)
7169 {
7170 init_tabs[i].flags&=~D_SELECTED;
7171 }
7172 init_tabs[0].flags=D_SELECTED;
7173 return onCheatConsole();
7174 }
7175 */
7176
7177 int32_t onItems()
7178 {
7179 for(int32_t i=0; i<MAXINITTABS; ++i)
7180 {
7181 init_tabs[i].flags&=~D_SELECTED;
7182 }
7183
7184 init_tabs[1].flags=D_SELECTED;
7185 return onCheatConsole();
7186 }
7187
7188 static DIALOG getnum_dlg[] =
7189 {
7190 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
7191 { jwin_win_proc, 80, 80, 160, 72, vc(0), vc(11), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
7192 { jwin_text_proc, 104, 104+4, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
7193 { jwin_edit_proc, 168, 104, 48, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
7194 { jwin_button_proc, 90, 126, 61, 21, vc(0), vc(11), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7195 { jwin_button_proc, 170, 126, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7196 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7197 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7198 };
7199
7200 int32_t getnumber(const char *prompt,int32_t initialval)
7201 {
7202 char buf[20];
7203 sprintf(buf,"%d",initialval);
7204 getnum_dlg[0].dp=(void *)prompt;
7205 getnum_dlg[0].dp2=get_zc_font(font_lfont);
7206 getnum_dlg[2].dp=buf;
7207
7208 large_dialog(getnum_dlg);
7209
7210 if(zc_popup_dialog(getnum_dlg,2)==3)
7211 return atoi(buf);
7212
7213 return initialval;
7214 }
7215
7216 int32_t onLife()
7217 {
7218 int value = vbound(getnumber("Life",game->get_life()),1,game->get_maxlife());
7219 cheats_enqueue(Cheat::Life, value);
7220 return D_O_K;
7221 }
7222
7223 int32_t onHeartC()
7224 {
7225 int max_life = vbound(getnumber("Heart Containers",game->get_maxlife()/game->get_hp_per_heart()),1,4095) * game->get_hp_per_heart();
7226 int life = vbound(getnumber("Life",game->get_life()/game->get_hp_per_heart()),1,max_life/game->get_hp_per_heart())*game->get_hp_per_heart();
7227 cheats_enqueue(Cheat::MaxLife, max_life);
7228 cheats_enqueue(Cheat::Life, life);
7229 return D_O_K;
7230 }
7231
7232 int32_t onMagicC()
7233 {
7234 int max_magic = vbound(getnumber("Magic Containers",game->get_maxmagic()/game->get_mp_per_block()),0,2047) * game->get_mp_per_block();
7235 int magic = vbound(getnumber("Magic",game->get_magic()/game->get_mp_per_block()),0,game->get_maxmagic()/game->get_mp_per_block())*game->get_mp_per_block();
7236 cheats_enqueue(Cheat::MaxMagic, max_magic);
7237 cheats_enqueue(Cheat::Magic, magic);
7238 return D_O_K;
7239 }
7240
7241 int32_t onRupies()
7242 {
7243 int value = vbound(getnumber("Rupees",game->get_rupies()),0,game->get_maxcounter(1));
7244 cheats_enqueue(Cheat::Rupies, value);
7245 return D_O_K;
7246 }
7247
7248 int32_t onMaxBombs()
7249 {
7250 int value = vbound(getnumber("Max Bombs",game->get_maxbombs()),0,0xFFFF);
7251 cheats_enqueue(Cheat::MaxBombs, value);
7252 cheats_enqueue(Cheat::Bombs, value);
7253 return D_O_K;
7254 }
7255
7256 int32_t onRefillLife()
7257 {
7258 cheats_enqueue(Cheat::Life, game->get_maxlife());
7259 return D_O_K;
7260 }
7261 int32_t onRefillMagic()
7262 {
7263 cheats_enqueue(Cheat::Magic, game->get_maxmagic());
7264 return D_O_K;
7265 }
7266 int32_t onClock()
7267 {
7268 cheats_enqueue(Cheat::Clock);
7269 return D_O_K;
7270 }
7271
7272 int32_t onQstPath()
7273 {
7274 char path[2048];
7275
7276 chop_path(qstdir);
7277 strcpy(path,qstdir);
7278
7279 go();
7280
7281 if(jwin_dfile_select_ex("Quest File Directory", path, "qst", 2048, -1, -1, get_zc_font(font_lfont)))
7282 {
7283 chop_path(path);
7284 fix_filename_case(path);
7285 fix_filename_slashes(path);
7286 strcpy(qstdir,path);
7287 strcpy(qstpath,qstdir);
7288 }
7289
7290 comeback();
7291 return D_O_K;
7292 }
7293
7294 #include "dialog/cheat_dialog.h"
7295 int32_t onCheat()
7296 {
7297 call_setcheat_dialog();
7298 game->set_cheat(maxcheat);
7299 if(cheat) game->did_cheat(true);
7300 return D_O_K;
7301 }
7302
7303 int32_t onCheatRupies()
7304 {
7305 cheats_enqueue(Cheat::Rupies, game->get_maxcounter(1));
7306 return D_O_K;
7307 }
7308
7309 int32_t onCheatArrows()
7310 {
7311 cheats_enqueue(Cheat::Arrows, game->get_maxarrows());
7312 return D_O_K;
7313 }
7314
7315 int32_t onCheatBombs()
7316 {
7317 cheats_enqueue(Cheat::Bombs, game->get_maxbombs(), game->get_maxcounter(6));
7318 return D_O_K;
7319 }
7320
7321 // *** screen saver
7322
7323 9284954 int32_t after_time()
7324 {
7325
1/2
✓ Branch 0 taken 9284954 times.
✗ Branch 1 not taken.
9284954 if(ss_enable == 0)
7326 return INT_MAX;
7327
7328
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9284954 times.
9284954 if(ss_after <= 0)
7329 return 5 * 60;
7330
7331
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9284954 times.
9284954 if(ss_after <= 3)
7332 return ss_after * 15 * 60;
7333
7334
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9284954 times.
9284954 if(ss_after <= 13)
7335 return (ss_after - 3) * 60 * 60;
7336
7337 9284954 return MAX_IDLE + 1;
7338 9284954 }
7339
7340 static const char *after_str[15] =
7341 {
7342 " 5 sec", "15 sec", "30 sec", "45 sec", " 1 min", " 2 min", " 3 min",
7343 " 4 min", " 5 min", " 6 min", " 7 min", " 8 min", " 9 min", "10 min",
7344 "Never"
7345 };
7346
7347 const char *after_list(int32_t index, int32_t *list_size)
7348 {
7349 if(index < 0)
7350 {
7351 *list_size = 15;
7352 return NULL;
7353 }
7354
7355 return after_str[index];
7356 }
7357
7358 116 static ListData after__list(after_list, &font);
7359
7360 static DIALOG scrsaver_dlg[] =
7361 {
7362 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
7363 116 { jwin_win_proc, 32, 64, 256, 136, 0, 0, 0, D_EXIT, 0, 0, (void *) "Screen Saver Settings", NULL, NULL },
7364 116 { jwin_frame_proc, 42, 92, 236, 70, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
7365 116 { jwin_text_proc, 60, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Run After", NULL, NULL },
7366 116 { jwin_text_proc, 60, 128, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Speed", NULL, NULL },
7367 116 { jwin_text_proc, 60, 144, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Density", NULL, NULL },
7368 116 { jwin_droplist_proc, 144, 100, 96, 16, 0, 0, 0, 0, 0, 0, (void *) &after__list, NULL, NULL },
7369 116 { jwin_slider_proc, 144, 128, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7370 116 { jwin_slider_proc, 144, 144, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7371 116 { jwin_button_proc, 42, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7372 116 { jwin_button_proc, 124, 170, 72, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Preview", NULL, NULL },
7373 116 { jwin_button_proc, 218, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7374 116 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7375 116 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7376 };
7377
7378 int32_t onScreenSaver()
7379 {
7380 scrsaver_dlg[0].dp2=get_zc_font(font_lfont);
7381 int32_t oldcfgs[3];
7382 scrsaver_dlg[5].d1 = scrsaver_dlg[5].d2 = oldcfgs[0] = ss_after;
7383 scrsaver_dlg[6].d2 = oldcfgs[1] = ss_speed;
7384 scrsaver_dlg[7].d2 = oldcfgs[2] = ss_density;
7385
7386 large_dialog(scrsaver_dlg);
7387
7388 int32_t ret = zc_popup_dialog(scrsaver_dlg,-1);
7389
7390 if(ret == 8 || ret == 9)
7391 {
7392 ss_after = scrsaver_dlg[5].d1;
7393 ss_speed = scrsaver_dlg[6].d2;
7394 ss_density = scrsaver_dlg[7].d2;
7395 if(oldcfgs[0] != ss_after)
7396 zc_set_config(cfg_sect,"ss_after",ss_after);
7397 if(oldcfgs[1] != ss_speed)
7398 zc_set_config(cfg_sect,"ss_speed",ss_speed);
7399 if(oldcfgs[2] != ss_density)
7400 zc_set_config(cfg_sect,"ss_density",ss_density);
7401 }
7402
7403 if(ret == 9)
7404 // preview Screen Saver
7405 {
7406 clear_keybuf();
7407 Matrix(ss_speed, ss_density, 30);
7408 system_pal(true);
7409 sys_mouse();
7410 }
7411
7412 return D_O_K;
7413 }
7414
7415 /***** Menus *****/
7416
7417 static MENU game_menu[] =
7418 {
7419 { (char *)"&Continue\tESC", onContinue, NULL, 0, NULL },
7420 { (char *)"", NULL, NULL, 0, NULL },
7421 { (char *)"L&oad Quest...", onCustomGame, NULL, 0, NULL },
7422 { (char *)"&End Game\tF6", onTryQuitMenu, NULL, 0, NULL },
7423 { (char *)"", NULL, NULL, 0, NULL },
7424 #ifdef __EMSCRIPTEN__
7425 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7426 #elif defined(ALLEGRO_MACOSX)
7427 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7428 { (char *)"&Quit\tF8", onExit, NULL, 0, NULL },
7429 #else
7430 { (char *)"&Reset\tF9", onReset, NULL, 0, NULL },
7431 { (char *)"&Quit\tF10", onExit, NULL, 0, NULL },
7432 #endif
7433 { NULL, NULL, NULL, 0, NULL }
7434 };
7435
7436 static MENU title_menu[] =
7437 {
7438 { (char *)"&Original", onTitle_NES, NULL, 0, NULL },
7439 { (char *)"&ZQuest Classic", onTitle_DX, NULL, 0, NULL },
7440 { (char *)"ZQuest Classic &2.50", onTitle_25, NULL, 0, NULL },
7441 { NULL, NULL, NULL, 0, NULL }
7442 };
7443
7444 static MENU snapshot_format_menu[] =
7445 {
7446 { (char *)"&BMP", onSetSnapshotFormat, NULL, 0, NULL },
7447 { (char *)"&GIF", onSetSnapshotFormat, NULL, 0, NULL },
7448 { (char *)"&JPG", onSetSnapshotFormat, NULL, 0, NULL },
7449 { (char *)"&PNG", onSetSnapshotFormat, NULL, 0, NULL },
7450 { (char *)"PC&X", onSetSnapshotFormat, NULL, 0, NULL },
7451 { (char *)"&TGA", onSetSnapshotFormat, NULL, 0, NULL },
7452 { NULL, NULL, NULL, 0, NULL }
7453 };
7454
7455 static MENU controls_menu[] =
7456 {
7457 { (char *)"Key&board...", onKeyboard, NULL, 0, NULL },
7458 { (char *)"&Gamepad...", onGamepad, NULL, 0, NULL },
7459 { (char *)"&Cheat Keys...", onCheatKeys, NULL, 0, NULL },
7460 { NULL, NULL, NULL, 0, NULL }
7461 };
7462
7463 static MENU name_entry_mode_menu[] =
7464 {
7465 { (char *)"&Keyboard", onKeyboardEntry, NULL, 0, NULL },
7466 { (char *)"&Letter Grid", onLetterGridEntry, NULL, 0, NULL },
7467 { (char *)"&Extended Letter Grid", onExtLetterGridEntry, NULL, 0, NULL },
7468 { NULL, NULL, NULL, 0, NULL }
7469 };
7470
7471 static void set_controls_menu_active()
7472 {
7473
7474 }
7475
7476 static MENU window_menu[] =
7477 {
7478 { "Lock Aspect Ratio", onDragAspect, NULL, 0, NULL },
7479 { "Lock Integer Scale", onIntegerScaling, NULL, 0, NULL },
7480 { "Save Size Changes", onSaveDragResize, NULL, 0, NULL },
7481 { "Save Position Changes", onWinPosSave, NULL, 0, NULL },
7482 { "Stretch Game Area", onStretchGame, NULL, 0, NULL },
7483 { NULL, NULL, NULL, 0, NULL }
7484 };
7485 static MENU options_menu[] =
7486 {
7487 { "&Title Screen", NULL, title_menu, 0, NULL },
7488 { "Name &Entry Mode", NULL, name_entry_mode_menu, 0, NULL },
7489 { "S&napshot Format", NULL, snapshot_format_menu, 0, NULL },
7490 { "&Window Settings", NULL, window_menu, 0, NULL },
7491 { "Epilepsy Flash Reduction", onEpilepsy, NULL, 0, NULL },
7492 { "Pause In Background", onPauseInBackground, NULL, 0, NULL },
7493 { NULL, NULL, NULL, 0, NULL }
7494 };
7495 static MENU settings_menu[] =
7496 {
7497 { "&Sound...", onSound, NULL, 0, NULL },
7498 { "C&ontrols", NULL, controls_menu, 0, NULL },
7499 { "", NULL, NULL, 0, NULL },
7500 { "Options", NULL, options_menu, 0, NULL },
7501 { "", NULL, NULL, 0, NULL },
7502 //
7503 { "&Cap FPS\tF1", onVsync, NULL, 0, NULL },
7504 { "Show &FPS\tF2", onShowFPS, NULL, 0, NULL },
7505 { "Click to Freeze", onClickToFreeze, NULL, 0, NULL },
7506 { "Cont. &Heart Beep", onHeartBeep, NULL, 0, NULL },
7507 { "Show Trans. &Layers", onTransLayers, NULL, 0, NULL },
7508 //
7509 { "Up+A+B To &Quit", onNESquit, NULL, 0, NULL },
7510 { "Volume &Keys", onVolKeys, NULL, 0, NULL },
7511 { "Sa&ve Indicator", onSaveIndicator, NULL, 0, NULL },
7512 { "", NULL, NULL, 0, NULL },
7513 { "Debu&g", onDebug, NULL, 0, NULL },
7514 //
7515 { NULL, NULL, NULL, 0, NULL }
7516 };
7517
7518
7519 static MENU misc_menu[] =
7520 {
7521 { (char *)"&About...", onAbout, NULL, 0, NULL },
7522 { (char *)"&Credits...", onCredits, NULL, 0, NULL },
7523 { (char *)"&Fullscreen", onFullscreenMenu, NULL, 0, NULL },
7524 { (char *)"&Video Mode...", onVidMode, NULL, 0, NULL },
7525 { (char *)"", NULL, NULL, 0, NULL },
7526 //5
7527 { (char *)"&Quest Info...", onQuest, NULL, 0, NULL },
7528 { (char *)"Quest &MIDI Info...", onMIDICredits, NULL, 0, NULL },
7529 { (char *)"Quest &Directory...", onQstPath, NULL, 0, NULL },
7530 { (char *)"", NULL, NULL, 0, NULL },
7531 { (char *)"Take &Snapshot\tF12", onSnapshot, NULL, 0, NULL },
7532 //10
7533 { (char *)"Sc&reen Saver...", onScreenSaver, NULL, 0, NULL },
7534 { (char *)"Save ZC Configuration", OnSaveZCConfig, NULL, 0, NULL },
7535 { (char *)"Show ZASM Debugger", onConsoleZASM, NULL, 0, NULL },
7536 { (char *)"Show ZScript Debugger", onConsoleZScript, NULL, 0, NULL },
7537 { (char *)"Clear Console on Qst Load", onClrConsoleOnLoad, NULL, 0, NULL },
7538 //15
7539 { (char *)"Clear Directory Cache", OnnClearQuestDir, NULL, 0, NULL },
7540 { (char *)"Modules", NULL, zcmodule_menu, 0, NULL },
7541 { NULL, NULL, NULL, 0, NULL }
7542 };
7543
7544 static MENU refill_menu[] =
7545 {
7546 { (char *)"&Life", onRefillLife, NULL, 0, NULL },
7547 { (char *)"&Magic", onRefillMagic, NULL, 0, NULL },
7548 { (char *)"&Bombs", onCheatBombs, NULL, 0, NULL },
7549 { (char *)"&Rupees", onCheatRupies, NULL, 0, NULL },
7550 { (char *)"&Arrows", onCheatArrows, NULL, 0, NULL },
7551 { NULL, NULL, NULL, 0, NULL }
7552 };
7553
7554 static MENU show_menu[] =
7555 {
7556 { (char *)"Combos", onShowLayer0, NULL, 0, NULL },
7557 { (char *)"Layer 1", onShowLayer1, NULL, 0, NULL },
7558 { (char *)"Layer 2", onShowLayer2, NULL, 0, NULL },
7559 { (char *)"Layer 3", onShowLayer3, NULL, 0, NULL },
7560 { (char *)"Layer 4", onShowLayer4, NULL, 0, NULL },
7561 { (char *)"Layer 5", onShowLayer5, NULL, 0, NULL },
7562 { (char *)"Layer 6", onShowLayer6, NULL, 0, NULL },
7563 { (char *)"Overhead Combos", onShowLayerO, NULL, 0, NULL },
7564 { (char *)"Push Blocks", onShowLayerP, NULL, 0, NULL },
7565 { (char *)"Freeform Combos", onShowLayerF, NULL, 0, NULL },
7566 { (char *)"Sprites", onShowLayerS, NULL, 0, NULL },
7567 { (char *)"", NULL, NULL, 0, NULL },
7568 { (char *)"Current FFC Scripts", onShowFFScripts, NULL, 0, NULL },
7569 { (char *)"", NULL, NULL, 0, NULL },
7570 { (char *)"Walkability", onShowLayerW, NULL, 0, NULL },
7571 { (char *)"Hitboxes", onShowHitboxes, NULL, 0, NULL },
7572 { (char *)"Effects", onShowLayerE, NULL, 0, NULL },
7573 { (char *)"Info Opacity", onShowInfoOpacity, NULL, 0, NULL },
7574 { NULL, NULL, NULL, 0, NULL }
7575 };
7576
7577 static MENU cheat_menu[] =
7578 {
7579 { (char *)"Set &Cheat", onCheat, NULL, 0, NULL },
7580 { (char *)"", NULL, NULL, 0, NULL },
7581 { (char *)"Re&fill", NULL, refill_menu, 0, NULL },
7582 { (char *)"", NULL, NULL, 0, NULL },
7583 { (char *)"&Invincible", onClock, NULL, 0, NULL },
7584 { (char *)"Ma&x Bombs...", onMaxBombs, NULL, 0, NULL },
7585 { (char *)"&Heart Containers...", onHeartC, NULL, 0, NULL },
7586 { (char *)"&Magic Containers...", onMagicC, NULL, 0, NULL },
7587 { (char *)"", NULL, NULL, 0, NULL },
7588 { (char *)"&Player Data...", onCheatConsole, NULL, 0, NULL },
7589 { (char *)"", NULL, NULL, 0, NULL },
7590 { (char *)"Walk Through &Walls", onNoWalls, NULL, 0, NULL },
7591 { (char *)"Player Ignores Side&view", onIgnoreSideview, NULL, 0, NULL },
7592 { (char *)"&Quick Movement", onGoFast, NULL, 0, NULL },
7593 { (char *)"&Kill All Enemies", onKillCheat, NULL, 0, NULL },
7594 { (char *)"Trigger &Secrets", onSecretsCheat, NULL, 0, NULL },
7595 { (char *)"Trigger Secrets Perm", onSecretsCheatPerm, NULL, 0, NULL },
7596 { (char *)"Show/Hide Layer", NULL, show_menu, 0, NULL },
7597 { (char *)"Toggle &Light", onLightSwitch, NULL, 0, NULL },
7598 { (char *)"&Goto Location...", onGoTo, NULL, 0, NULL },
7599 { NULL, NULL, NULL, 0, NULL }
7600 };
7601
7602 #if DEVLEVEL > 0
7603 int32_t devLogging();
7604 int32_t devDebug();
7605 int32_t devTimestmp();
7606 #if DEVLEVEL > 1
7607 int32_t setCheat();
7608 #endif //DEVLEVEL > 1
7609 enum
7610 {
7611 dv_log,
7612 // dv_dbg,
7613 dv_tmpstmp,
7614 #if DEVLEVEL > 1
7615 dv_nil,
7616 dv_setcheat,
7617 #endif //DEVLEVEL > 1
7618 dv_max
7619 };
7620 static MENU dev_menu[] =
7621 {
7622 { (char *)"&Force Error Log", devLogging, NULL, 0, NULL },
7623 // { (char *)"&Extra Debug Log", devDebug, NULL, 0, NULL },
7624 { (char *)"&Timestamp Log", devTimestmp, NULL, 0, NULL },
7625 #if DEVLEVEL > 1
7626 { (char *)"", NULL, NULL, 0, NULL },
7627 { (char *)"Set &Cheat", setCheat, NULL, 0, NULL },
7628 #endif //DEVLEVEL > 1
7629 { NULL, NULL, NULL, 0, NULL }
7630 };
7631 int32_t devLogging()
7632 {
7633 dev_logging = !dev_logging;
7634 dev_menu[dv_log].flags = dev_logging ? D_SELECTED : 0;
7635 return D_O_K;
7636 }
7637 // int32_t devDebug()
7638 // {
7639 // dev_debug = !dev_debug;
7640 // dev_menu[dv_dbg].flags = dev_debug ? D_SELECTED : 0;
7641 // return D_O_K;
7642 // }
7643 int32_t devTimestmp()
7644 {
7645 dev_timestmp = !dev_timestmp;
7646 dev_menu[dv_tmpstmp].flags = dev_timestmp ? D_SELECTED : 0;
7647 return D_O_K;
7648 }
7649 #if DEVLEVEL > 1
7650 int32_t setCheat()
7651 {
7652 cheat = (vbound(getnumber("Cheat Level",cheat), 0, 4));
7653 return D_O_K;
7654 }
7655 #endif //DEVLEVEL > 1
7656 #endif //DEVLEVEL > 0
7657
7658 MENU the_player_menu[] =
7659 {
7660 { (char *)"&Game", NULL, game_menu, 0, NULL },
7661 { (char *)"&Settings", NULL, settings_menu, 0, NULL },
7662 { (char *)"&Cheat", NULL, cheat_menu, 0, NULL },
7663 { (char *)"Replay", NULL, replay_menu, 0, NULL },
7664 { (char *)"&ZC", NULL, misc_menu, 0, NULL },
7665 #if DEVLEVEL > 0
7666 { (char *)"&Dev", NULL, dev_menu, 0, NULL },
7667 #endif
7668 { NULL, NULL, NULL, 0, NULL }
7669 };
7670 int32_t onPauseInBackground()
7671 {
7672 if(jwin_alert3(
7673 "Toggle Pause In Background",
7674 "This action will change whether ZC Player pauses when the window loses focus.",
7675 "",
7676 "Proceed?",
7677 "&Yes",
7678 "&No",
7679 NULL,
7680 'y',
7681 'n',
7682 0,
7683 get_zc_font(font_lfont)) == 1)
7684 {
7685 pause_in_background = pause_in_background ? 0 : 1;
7686 zc_set_config("zeldadx","pause_in_background", pause_in_background);
7687 int switch_type = pause_in_background ? SWITCH_PAUSE : SWITCH_BACKGROUND;
7688 set_display_switch_mode(fullscreen?SWITCH_BACKAMNESIA:switch_type);
7689 set_display_switch_callback(SWITCH_OUT, switch_out_callback);
7690 set_display_switch_callback(SWITCH_IN, switch_in_callback);
7691 }
7692 options_menu[5].flags =(pause_in_background)?D_SELECTED:0;
7693 return D_O_K;
7694 }
7695
7696 int32_t onKeyboardEntry()
7697 {
7698 NameEntryMode=0;
7699 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7700 return D_O_K;
7701 }
7702
7703 int32_t onLetterGridEntry()
7704 {
7705 NameEntryMode=1;
7706 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7707 return D_O_K;
7708 }
7709
7710 int32_t onExtLetterGridEntry()
7711 {
7712 NameEntryMode=2;
7713 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7714 return D_O_K;
7715 }
7716
7717 static BITMAP* oldscreen;
7718 int32_t onFullscreenMenu()
7719 {
7720 // super hacks
7721 screen = oldscreen;
7722 if (onFullscreen() == D_REDRAW)
7723 {
7724 oldscreen = screen;
7725 }
7726 screen = menu_bmp;
7727 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
7728 return D_O_K;
7729 }
7730
7731 116 void fix_menu()
7732 {
7733
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(!debug_enabled)
7734 116 settings_menu[13].text = NULL;
7735 116 }
7736
7737 static DIALOG system_dlg[] =
7738 {
7739 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
7740 { jwin_menu_proc, 0, 0, 0, 0, 0, 0, 0, D_USER, 0, 0, (void *) the_player_menu, NULL, NULL },
7741 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onVsync, NULL, NULL },
7742 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F2, 0, (void *) onShowFPS, NULL, NULL },
7743 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F6, 0, (void *) onTryQuitMenu, NULL, NULL },
7744 #ifndef ALLEGRO_MACOSX
7745 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F9, 0, (void *) onReset, NULL, NULL },
7746 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F10, 0, (void *) onExit, NULL, NULL },
7747 #else
7748 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F7, 0, (void *) onReset, NULL, NULL },
7749 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F8, 0, (void *) onExit, NULL, NULL },
7750 #endif
7751 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F12, 0, (void *) onSnapshot, NULL, NULL },
7752 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_TAB, 0, (void *) onDebug, NULL, NULL },
7753 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7754 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7755 };
7756
7757 void reset_snapshot_format_menu()
7758 {
7759 for(int32_t i=0; i<ssfmtMAX; ++i)
7760 {
7761 snapshot_format_menu[i].flags=0;
7762 }
7763 }
7764
7765 int32_t onSetSnapshotFormat()
7766 {
7767 switch(active_menu->text[1])
7768 {
7769 case 'B': //"&BMP"
7770 SnapshotFormat=0;
7771 break;
7772
7773 case 'G': //"&GIF"
7774 SnapshotFormat=1;
7775 break;
7776
7777 case 'J': //"&JPG"
7778 SnapshotFormat=2;
7779 break;
7780
7781 case 'P': //"&PNG"
7782 SnapshotFormat=3;
7783 break;
7784
7785 case 'C': //"PC&X"
7786 SnapshotFormat=4;
7787 break;
7788
7789 case 'T': //"&TGA"
7790 SnapshotFormat=5;
7791 break;
7792
7793 case 'L': //"&LBM"
7794 SnapshotFormat=6;
7795 break;
7796 }
7797 zc_set_config("zeldadx", "snapshot_format", SnapshotFormat);
7798
7799 snapshot_format_menu[SnapshotFormat].flags=D_SELECTED;
7800 return D_O_K;
7801 }
7802
7803
7804 void color_layer(RGB *src,RGB *dest,char r,char g,char b,char pos,int32_t from,int32_t to)
7805 {
7806 PALETTE tmp;
7807
7808 for(int32_t i=0; i<256; i++)
7809 {
7810 tmp[i].r=r;
7811 tmp[i].g=g;
7812 tmp[i].b=b;
7813 }
7814
7815 fade_interpolate(src,tmp,dest,pos,from,to);
7816 }
7817
7818 13 void system_pal(bool force)
7819 {
7820
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13 if(is_sys_pal && !force) return;
7821 13 is_sys_pal = true;
7822 13 load_colorset(gui_colorset, syspal, jwin_a5_colors);
7823 13 hw_palette = &syspal;
7824 13 update_hw_pal = true;
7825 13 }
7826
7827 static uint32_t entered_sys_pal = 0;
7828 13 void enter_sys_pal()
7829 {
7830
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(is_sys_pal)
7831 {
7832 if(entered_sys_pal)
7833 ++entered_sys_pal;
7834 return;
7835 }
7836 13 sys_mouse();
7837 13 system_pal(true);
7838 13 ++entered_sys_pal;
7839 13 }
7840 13 void exit_sys_pal()
7841 {
7842
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(entered_sys_pal)
7843 {
7844
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!--entered_sys_pal)
7845 {
7846 13 game_pal();
7847 13 game_mouse();
7848 13 }
7849 13 }
7850 13 }
7851
7852 void switch_out_callback()
7853 {
7854 if (pause_in_background && !MenuOpen)
7855 {
7856 System();
7857 }
7858 }
7859
7860 void switch_in_callback()
7861 {
7862 }
7863
7864 421 void game_pal()
7865 {
7866 421 is_sys_pal = false;
7867 421 entered_sys_pal = 0;
7868 421 hw_palette = &RAMpal;
7869 421 update_hw_pal = true;
7870 421 }
7871
7872 static char bar_str[] = "";
7873
7874 13 void music_pause()
7875 {
7876 //al_pause_duh(tmplayer);
7877 13 zcmusic_pause(zcmusic, ZCM_PAUSE);
7878
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(zcmixer->oldtrack)
7879 zcmusic_pause(zcmixer->oldtrack, ZCM_PAUSE);
7880 13 zc_midi_pause();
7881 13 }
7882
7883 void music_resume()
7884 {
7885 //al_resume_duh(tmplayer);
7886 zcmusic_pause(zcmusic, ZCM_RESUME);
7887 if (zcmixer->oldtrack)
7888 zcmusic_pause(zcmixer->oldtrack, ZCM_RESUME);
7889 zc_midi_resume();
7890 }
7891
7892 3358 void music_stop()
7893 {
7894 //al_stop_duh(tmplayer);
7895 //unload_duh(tmusic);
7896 //tmusic=NULL;
7897 //tmplayer=NULL;
7898 3358 zcmusic_stop(zcmusic);
7899 3358 zcmusic_unload_file(zcmusic);
7900
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3358 times.
3358 if (zcmixer->oldtrack)
7901 {
7902 zcmusic_stop(zcmixer->oldtrack);
7903 zcmusic_unload_file(zcmixer->oldtrack);
7904 }
7905 //if (zcmixer->newtrack)
7906 //{
7907 // zcmusic_stop(zcmixer->newtrack);
7908 // zcmusic_unload_file(zcmixer->newtrack);
7909 //}
7910 3358 zc_stop_midi();
7911 3358 currmidi=-1;
7912 3358 }
7913
7914 void System()
7915 {
7916 mouse_down=gui_mouse_b();
7917 music_pause();
7918 pause_all_sfx();
7919 MenuOpen = true;
7920 enter_sys_pal();
7921 // FONT *oldfont=font;
7922 // font=tfont;
7923
7924 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
7925 misc_menu[3].flags =(isFullScreen()==1)?D_DISABLED:0;
7926
7927 game_menu[2].flags = getsaveslot() > -1 ? 0 : D_DISABLED;
7928 #if DEVLEVEL > 1
7929 dev_menu[dv_setcheat].flags = Playing ? 0 : D_DISABLED;
7930 #endif
7931 game_menu[3].flags =
7932 misc_menu[5].flags = Playing ? 0 : D_DISABLED;
7933 misc_menu[7].flags = !Playing ? 0 : D_DISABLED;
7934 clear_keybuf();
7935
7936 DIALOG_PLAYER *p;
7937
7938 clear_bitmap(menu_bmp);
7939 oldscreen = screen;
7940 screen = menu_bmp;
7941
7942 p = init_dialog(system_dlg,-1);
7943
7944 // drop the menu on startup if menu button pressed
7945 if(joybtn(Mbtn)||zc_getrawkey(KEY_ESC))
7946 simulate_keypress(KEY_G << 8);
7947
7948 do
7949 {
7950 if(close_button_quit)
7951 {
7952 close_button_quit = false;
7953 f_Quit(qEXIT);
7954 if(Quit) break;
7955 }
7956 rest(17);
7957
7958 if(mouse_down && !gui_mouse_b())
7959 mouse_down=0;
7960
7961 title_menu[0].flags = (title_version==0) ? D_SELECTED : 0;
7962 title_menu[1].flags = (title_version==1) ? D_SELECTED : 0;
7963 title_menu[2].flags = (title_version==2) ? D_SELECTED : 0;
7964
7965 settings_menu[1].flags = replay_is_replaying() ? D_DISABLED : 0;
7966 settings_menu[5].flags = Throttlefps?D_SELECTED:0;
7967 settings_menu[6].flags = ShowFPS?D_SELECTED:0;
7968 settings_menu[7].flags = ClickToFreeze?D_SELECTED:0;
7969 settings_menu[9].flags = TransLayers?D_SELECTED:0;
7970 settings_menu[10].flags = NESquit?D_SELECTED:0;
7971 settings_menu[11].flags = volkeys?D_SELECTED:0;
7972
7973 window_menu[0].flags = DragAspect?D_SELECTED:0;
7974 window_menu[1].flags = scaleForceInteger?D_SELECTED:0;
7975 window_menu[2].flags = SaveDragResize?D_SELECTED:0;
7976 window_menu[3].flags = SaveWinPos?D_SELECTED:0;
7977 window_menu[4].flags = stretchGame?D_SELECTED:0;
7978
7979 options_menu[4].flags = (epilepsyFlashReduction) ? D_SELECTED : 0;
7980 options_menu[5].flags = (pause_in_background)?D_SELECTED:0;
7981
7982 name_entry_mode_menu[0].flags = (NameEntryMode==0)?D_SELECTED:0;
7983 name_entry_mode_menu[1].flags = (NameEntryMode==1)?D_SELECTED:0;
7984 name_entry_mode_menu[2].flags = (NameEntryMode==2)?D_SELECTED:0;
7985
7986 misc_menu[12].flags =(zasm_debugger)?D_SELECTED:0;
7987 misc_menu[13].flags =(zscript_debugger)?D_SELECTED:0;
7988 misc_menu[14].flags =(clearConsoleOnLoad)?D_SELECTED:0;
7989
7990 bool nocheat = (replay_is_replaying() || !Playing
7991 || (!zcheats.flags && !get_debug() && DEVLEVEL < 2 && !zqtesting_mode && !devpwd()));
7992 the_player_menu[2].flags = nocheat ? D_DISABLED : 0;
7993 cheat_menu[0].flags = 0;
7994 refill_menu[4].flags = get_qr(qr_TRUEARROWS) ? 0 : D_DISABLED;
7995 cheat_menu[1].text = (cheat >= 1) || get_debug() ? bar_str : NULL;
7996 cheat_menu[3].text = (cheat >= 2) || get_debug() ? bar_str : NULL;
7997 cheat_menu[8].text = (cheat >= 3) || get_debug() ? bar_str : NULL;
7998 cheat_menu[10].text = (cheat >= 4) || get_debug() ? bar_str : NULL;
7999 cheat_menu[4].flags = getClock() ? D_SELECTED : 0;
8000 cheat_menu[11].flags = toogam ? D_SELECTED : 0;
8001 cheat_menu[12].flags = ignoreSideview ? D_SELECTED : 0;
8002 cheat_menu[13].flags = gofast ? D_SELECTED : 0;
8003
8004 show_menu[0].flags = show_layer_0 ? D_SELECTED : 0;
8005 show_menu[1].flags = show_layer_1 ? D_SELECTED : 0;
8006 show_menu[2].flags = show_layer_2 ? D_SELECTED : 0;
8007 show_menu[3].flags = show_layer_3 ? D_SELECTED : 0;
8008 show_menu[4].flags = show_layer_4 ? D_SELECTED : 0;
8009 show_menu[5].flags = show_layer_5 ? D_SELECTED : 0;
8010 show_menu[6].flags = show_layer_6 ? D_SELECTED : 0;
8011 show_menu[7].flags = show_layer_over ? D_SELECTED : 0;
8012 show_menu[8].flags = show_layer_push ? D_SELECTED : 0;
8013 show_menu[9].flags = show_sprites ? D_SELECTED : 0;
8014 show_menu[10].flags = show_ffcs ? D_SELECTED : 0;
8015 show_menu[12].flags = show_walkflags ? D_SELECTED : 0;
8016 show_menu[13].flags = show_ff_scripts ? D_SELECTED : 0;
8017 show_menu[14].flags = show_hitboxes ? D_SELECTED : 0;
8018 show_menu[15].flags = show_effectflags ? D_SELECTED : 0;
8019
8020 settings_menu[8].flags = heart_beep ? D_SELECTED : 0;
8021 settings_menu[12].flags = use_save_indicator ? D_SELECTED : 0;
8022
8023 replay_menu[0].text = zc_get_config("zeldadx", "replay_new_saves", false) ?
8024 (char *)"Disable recording new saves" :
8025 (char *)"Enable recording new saves";
8026 replay_menu[1].flags = replay_is_active() ? 0 : D_DISABLED;
8027 replay_menu[1].text = replay_get_mode() == ReplayMode::Record ?
8028 (char *)"Stop recording" :
8029 (char *)"Stop replaying";
8030 replay_menu[5].flags = replay_get_mode() == ReplayMode::Record ? 0 : D_DISABLED;
8031 replay_menu[6].text = replay_is_snapshot_all_frames() ?
8032 (char *)"Disable snapshot all frames" :
8033 (char *)"Enable snapshot all frames";
8034
8035 reset_snapshot_format_menu();
8036 snapshot_format_menu[SnapshotFormat].flags = D_SELECTED;
8037
8038 if(debug_enabled)
8039 {
8040 settings_menu[14].flags = get_debug() ? D_SELECTED : 0;
8041 }
8042
8043 if(gui_mouse_b() && !mouse_down)
8044 break;
8045
8046 // press menu to drop the menu
8047 if(rMbtn())
8048 simulate_keypress(KEY_G << 8);
8049
8050 if(input_idle(true) > after_time())
8051 // run Screeen Saver
8052 {
8053 // Screen saver enabled for now.
8054 clear_keybuf();
8055 Matrix(ss_speed, ss_density, 0);
8056 system_pal(true);
8057 sys_mouse();
8058 broadcast_dialog_message(MSG_DRAW, 0);
8059 }
8060
8061 update_hw_screen();
8062 }
8063 while(update_dialog(p));
8064
8065 screen = oldscreen;
8066
8067 // font=oldfont;
8068 mouse_down=gui_mouse_b();
8069 shutdown_dialog(p);
8070 MenuOpen = false;
8071 if(Quit)
8072 {
8073 kill_sfx();
8074 music_stop();
8075 update_hw_screen();
8076 }
8077 else
8078 {
8079 music_resume();
8080 resume_all_sfx();
8081
8082 if(rc)
8083 ringcolor(false);
8084 }
8085 exit_sys_pal();
8086
8087 eat_buttons();
8088
8089 rc=false;
8090 clear_keybuf();
8091 // text_mode(0);
8092 }
8093
8094 116 void fix_dialogs()
8095 {
8096 116 jwin_center_dialog(about_dlg);
8097 116 jwin_center_dialog(gamepad_dlg);
8098 116 jwin_center_dialog(credits_dlg);
8099 116 jwin_center_dialog(gamemode_dlg);
8100 116 jwin_center_dialog(getnum_dlg);
8101 116 jwin_center_dialog(goto_dlg);
8102 116 jwin_center_dialog(keyboard_control_dlg);
8103 116 jwin_center_dialog(midi_dlg);
8104 116 jwin_center_dialog(quest_dlg);
8105 116 jwin_center_dialog(scrsaver_dlg);
8106 116 jwin_center_dialog(sound_dlg);
8107 116 jwin_center_dialog(triforce_dlg);
8108
8109 // digi_dp[1] += scrx;
8110 // digi_dp[2] += scry;
8111 // midi_dp[1] += scrx;
8112 // midi_dp[2] += scry;
8113 // pan_dp[1] += scrx;
8114 // pan_dp[2] += scry;
8115 // emus_dp[1] += scrx;
8116 // emus_dp[2] += scry;
8117 // buf_dp[1] += scrx;
8118 // buf_dp[2] += scry;
8119 // sfx_dp[1] += scrx;
8120 // sfx_dp[2] += scry;
8121 116 }
8122
8123 /*****************************/
8124 /**** Custom Sound System ****/
8125 /*****************************/
8126
8127 116 INLINE int32_t mixvol(int32_t v1,int32_t v2)
8128 {
8129
2/4
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 116 times.
✗ Branch 3 not taken.
116 return (zc_min(v1,255)*zc_min(v2,255)) >> 8;
8130 }
8131
8132 // Run an NSF, or a MIDI if the NSF is missing somehow.
8133 149 bool try_zcmusic(char *filename, int32_t track, int32_t midi, int32_t fadeoutframes)
8134 {
8135 149 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8136
8137 // Found it
8138
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 79 times.
149 if(newzcmusic!=NULL)
8139 {
8140 70 newzcmusic->fadevolume = 10000;
8141 70 newzcmusic->fadeoutframes = fadeoutframes;
8142
8143 70 zcmixer->newtrack = newzcmusic;
8144
8145 70 zcmusic_stop(zcmusic);
8146 70 zcmusic_unload_file(zcmusic);
8147 70 zc_stop_midi();
8148
8149 70 zcmusic=newzcmusic;
8150 70 int32_t temp_volume = emusic_volume;
8151
1/2
✓ Branch 0 taken 70 times.
✗ Branch 1 not taken.
70 if (!get_qr(qr_OLD_SCRIPT_VOLUME))
8152 temp_volume = (emusic_volume * FFCore.usr_music_volume) / 10000 / 100;
8153 70 temp_volume = (temp_volume * zcmusic->fadevolume) / 10000;
8154 70 zcmusic_play(zcmusic, temp_volume);
8155
8156
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70 times.
70 if(track>0)
8157 70 zcmusic_change_track(zcmusic,track);
8158
8159 70 return true;
8160 }
8161
8162 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8163
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 else if(midi>-1000)
8164 jukebox(midi);
8165
8166 79 return false;
8167 149 }
8168
8169 bool try_zcmusic_ex(char *filename, int32_t track, int32_t midi)
8170 {
8171 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8172 // Found it
8173 if(newzcmusic!=NULL)
8174 {
8175 zcmusic_stop(zcmusic);
8176 zcmusic_unload_file(zcmusic);
8177 zc_stop_midi();
8178
8179 zcmusic=newzcmusic;
8180 zcmusic_play(zcmusic, emusic_volume);
8181
8182 if(track>0)
8183 zcmusic_change_track(zcmusic,track);
8184
8185 return true;
8186 }
8187
8188 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8189 else if(midi>-1000)
8190 jukebox(midi);
8191
8192 return false;
8193 }
8194
8195 int32_t get_zcmusicpos()
8196 {
8197 int32_t debugtracething = zcmusic_get_curpos(zcmusic);
8198 return debugtracething;
8199 return 0;
8200 }
8201
8202 void set_zcmusicpos(int32_t position)
8203 {
8204 zcmusic_set_curpos(zcmusic, position);
8205 }
8206
8207 void set_zcmusicspeed(int32_t speed)
8208 {
8209 zcmusic_set_speed(zcmusic, speed);
8210 }
8211
8212 int32_t get_zcmusiclen()
8213 {
8214 return zcmusic_get_length(zcmusic);
8215 }
8216
8217 void set_zcmusicloop(double start, double end)
8218 {
8219 zcmusic_set_loop(zcmusic, start, end);
8220 }
8221
8222 63871 void jukebox(int32_t index,int32_t loop)
8223 {
8224
1/2
✓ Branch 0 taken 63871 times.
✗ Branch 1 not taken.
63871 if (is_headless())
8225 63871 return;
8226
8227 music_stop();
8228
8229 if(index<0) index=MAXMIDIS-1;
8230
8231 if(index>=MAXMIDIS) index=0;
8232
8233 music_stop();
8234
8235 // Allegro's DIGMID driver (the one normally used on on Linux) gets
8236 // stuck notes when a song stops. This fixes it.
8237 if(strcmp(midi_driver->name, "DIGMID")==0)
8238 zc_set_volume(0, 0);
8239
8240 zc_set_volume(-1, mixvol(tunes[index].volume, midi_volume >>1));
8241 zc_play_midi((MIDI*)tunes[index].data,loop);
8242
8243 if(tunes[index].start>0)
8244 zc_midi_seek(tunes[index].start);
8245
8246 midi_loop_start = tunes[index].loop_start;
8247 midi_loop_end = tunes[index].loop_end;
8248
8249 currmidi=index;
8250 master_volume(digi_volume, midi_volume);
8251 //midi_paused=false;
8252 63871 }
8253
8254 63871 void jukebox(int32_t index)
8255 {
8256
1/2
✓ Branch 0 taken 63871 times.
✗ Branch 1 not taken.
63871 if(index<0) index=MAXMIDIS-1;
8257
8258
1/2
✓ Branch 0 taken 63871 times.
✗ Branch 1 not taken.
63871 if(index>=MAXMIDIS) index=0;
8259
8260 // do nothing if it's already playing
8261
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 63871 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
63871 if(index==currmidi && midi_pos>=0)
8262 {
8263 return;
8264 }
8265
8266 63871 jukebox(index,tunes[index].loop);
8267 63871 }
8268
8269 16 void play_DmapMusic()
8270 {
8271
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if (is_headless())
8272 16 return;
8273
8274 static char tfile[2048];
8275 static int32_t ttrack=0;
8276 bool domidi=false;
8277
8278 int32_t fadeoutframes = 0;
8279 if (zcmusic != NULL)
8280 fadeoutframes = zcmusic->fadeoutframes;
8281
8282 if(DMaps[currdmap].tmusic[0]!=0)
8283 {
8284 if(zcmusic==NULL ||
8285 strcmp(zcmusic->filename,DMaps[currdmap].tmusic)!=0 ||
8286 (zcmusic->type==ZCMF_GME && zcmusic->track != DMaps[currdmap].tmusictrack))
8287 {
8288 if (DMaps[currdmap].tmusic_xfade_in > 0 || fadeoutframes > 0)
8289 {
8290 if (FFCore.play_enh_music_crossfade(DMaps[currdmap].tmusic, DMaps[currdmap].tmusictrack, DMaps[currdmap].tmusic_xfade_in, fadeoutframes))
8291 {
8292 if (zcmusic != NULL)
8293 {
8294 zcmusic->fadeoutframes = DMaps[currdmap].tmusic_xfade_out;
8295 zcmusic_set_loop(zcmusic, double(DMaps[currdmap].tmusic_loop_start / 10000.0), double(DMaps[currdmap].tmusic_loop_end / 10000.0));
8296 }
8297 }
8298 }
8299 else
8300 {
8301 if (zcmusic != NULL)
8302 {
8303 zcmusic_stop(zcmusic);
8304 zcmusic_unload_file(zcmusic);
8305 zcmusic = NULL;
8306 zcmixer->newtrack = NULL;
8307 }
8308
8309 zcmusic = zcmusic_load_for_quest(DMaps[currdmap].tmusic, qstpath);
8310 zcmixer->newtrack = zcmusic;
8311
8312 if (zcmusic != NULL)
8313 {
8314 zc_stop_midi();
8315 strcpy(tfile, DMaps[currdmap].tmusic);
8316 zcmusic_play(zcmusic, emusic_volume);
8317 int32_t temptracks = 0;
8318 temptracks = zcmusic_get_tracks(zcmusic);
8319 temptracks = (temptracks < 2) ? 1 : temptracks;
8320 ttrack = vbound(DMaps[currdmap].tmusictrack, 0, temptracks - 1);
8321 zcmusic_change_track(zcmusic, ttrack);
8322 zcmusic_set_loop(zcmusic, double(DMaps[currdmap].tmusic_loop_start / 10000.0), double(DMaps[currdmap].tmusic_loop_end / 10000.0));
8323 }
8324 else
8325 {
8326 tfile[0] = 0;
8327 domidi = true;
8328 }
8329 }
8330 }
8331 }
8332 else
8333 {
8334 if (DMaps[currdmap].midi == 0 && fadeoutframes > 0 && zcmusic != NULL && strcmp(zcmusic->filename, DMaps[currdmap].tmusic) != 0)
8335 {
8336 FFCore.play_enh_music_crossfade(NULL, DMaps[currdmap].tmusictrack, DMaps[currdmap].tmusic_xfade_in, fadeoutframes);
8337 }
8338 else if(zcmixer->oldtrack == NULL && zcmixer->newtrack == NULL)
8339 {
8340 domidi = true;
8341 }
8342 }
8343
8344 if(domidi)
8345 {
8346 int32_t m=DMaps[currdmap].midi;
8347
8348 switch(m)
8349 {
8350 case 1:
8351 jukebox(ZC_MIDI_OVERWORLD);
8352 break;
8353
8354 case 2:
8355 jukebox(ZC_MIDI_DUNGEON);
8356 break;
8357
8358 case 3:
8359 jukebox(ZC_MIDI_LEVEL9);
8360 break;
8361
8362 default:
8363 if(m>=4 && m<4+MAXCUSTOMMIDIS)
8364 jukebox(m+MIDIOFFSET_DMAP);
8365 else
8366 music_stop();
8367 }
8368 }
8369 16 }
8370
8371 15753 void playLevelMusic()
8372 {
8373
1/2
✓ Branch 0 taken 15753 times.
✗ Branch 1 not taken.
15753 if (is_headless())
8374 15753 return;
8375
8376 int32_t m=tmpscr->screen_midi;
8377
8378 switch(m)
8379 {
8380 case -2:
8381 music_stop();
8382 break;
8383
8384 case -1:
8385 play_DmapMusic();
8386 break;
8387
8388 case 1:
8389 jukebox(ZC_MIDI_OVERWORLD);
8390 break;
8391
8392 case 2:
8393 jukebox(ZC_MIDI_DUNGEON);
8394 break;
8395
8396 case 3:
8397 jukebox(ZC_MIDI_LEVEL9);
8398 break;
8399
8400 default:
8401 if(m>=4 && m<4+MAXCUSTOMMIDIS)
8402 jukebox(m+MIDIOFFSET_MAPSCR);
8403 else
8404 music_stop();
8405 }
8406 15753 }
8407
8408 116 void master_volume(int32_t dv,int32_t mv)
8409 {
8410
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
✓ Branch 2 taken 116 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 116 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 116 times.
✗ Branch 7 not taken.
116 if(dv>=0) digi_volume=zc_max(zc_min(dv,255),0);
8411
8412
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
✓ Branch 2 taken 116 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 116 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 116 times.
✗ Branch 7 not taken.
116 if(mv>=0) midi_volume=zc_max(zc_min(mv,255),0);
8413
8414
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
✓ Branch 2 taken 116 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 116 times.
116 int32_t i = zc_min(zc_max(currmidi,0),MAXMIDIS-1);
8415 116 int32_t temp_vol = midi_volume;
8416
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if (!get_qr(qr_OLD_SCRIPT_VOLUME))
8417 116 temp_vol = (midi_volume * FFCore.usr_music_volume) / 10000 / 100;
8418 116 zc_set_volume(digi_volume,mixvol(tunes[i].volume, temp_vol));
8419 116 }
8420
8421 /*****************/
8422 /***** SFX *****/
8423 /*****************/
8424
8425 // array of voices, one for each sfx sample in the data file
8426 // 0+ = voice #
8427 // -1 = voice not allocated
8428 116 void Z_init_sound()
8429 {
8430
2/2
✓ Branch 0 taken 29696 times.
✓ Branch 1 taken 116 times.
29812 for(int32_t i=0; i<WAV_COUNT; i++)
8431 29696 sfx_voice[i]=-1;
8432
8433
2/2
✓ Branch 0 taken 812 times.
✓ Branch 1 taken 116 times.
928 for(int32_t i=0; i<ZC_MIDI_COUNT; i++)
8434 812 tunes[i].data = (MIDI*)mididata[i].dat;
8435
8436
2/2
✓ Branch 0 taken 29232 times.
✓ Branch 1 taken 116 times.
29348 for(int32_t j=0; j<MAXCUSTOMMIDIS; j++)
8437 29232 tunes[ZC_MIDI_COUNT+j].data=NULL;
8438
8439 116 master_volume(digi_volume,midi_volume);
8440 116 }
8441
8442 // returns number of voices currently allocated
8443 int32_t sfx_count()
8444 {
8445 int32_t c=0;
8446
8447 for(int32_t i=0; i<WAV_COUNT; i++)
8448 if(sfx_voice[i]!=-1)
8449 ++c;
8450
8451 return c;
8452 }
8453
8454 // clean up finished samples
8455 9216210 void sfx_cleanup()
8456 {
8457
2/2
✓ Branch 0 taken 2359349760 times.
✓ Branch 1 taken 9216210 times.
2368565970 for(int32_t i=0; i<WAV_COUNT; i++)
8458
3/4
✓ Branch 0 taken 619254 times.
✓ Branch 1 taken 2358730506 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 619254 times.
2359969014 if(sfx_voice[i]!=-1 && voice_get_position(sfx_voice[i])<0)
8459 {
8460 619254 deallocate_voice(sfx_voice[i]);
8461 619254 sfx_voice[i]=-1;
8462 619254 }
8463 9216210 }
8464
8465 // allocates a voice for the sample "wav_index" (index into zelda.dat)
8466 // if a voice is already allocated (and/or playing), then it just returns true
8467 // Returns true: voice is allocated
8468 // false: unsuccessful
8469 963608 bool sfx_init(int32_t index)
8470 {
8471 // check index
8472
3/4
✓ Branch 0 taken 721282 times.
✓ Branch 1 taken 242326 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 721282 times.
963608 if(index<=0 || index>=WAV_COUNT)
8473 242326 return false;
8474
8475
2/2
✓ Branch 0 taken 102011 times.
✓ Branch 1 taken 619271 times.
721282 if(sfx_voice[index]==-1)
8476 {
8477
2/2
✓ Branch 0 taken 209876 times.
✓ Branch 1 taken 409395 times.
619271 if(sfxdat)
8478 {
8479
1/2
✓ Branch 0 taken 209876 times.
✗ Branch 1 not taken.
209876 if(index<Z35)
8480 {
8481 209876 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[index].dat);
8482 209876 }
8483 else
8484 {
8485 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[Z35].dat);
8486 }
8487 209876 }
8488 else
8489 {
8490 409395 sfx_voice[index]=allocate_voice(&customsfxdata[index]);
8491 }
8492
8493 619271 int32_t temp_volume = sfx_volume;
8494
1/2
✓ Branch 0 taken 619271 times.
✗ Branch 1 not taken.
619271 if (!get_qr(qr_OLD_SCRIPT_VOLUME))
8495 temp_volume = (sfx_volume * FFCore.usr_sfx_volume) / 10000 / 100;
8496 619271 voice_set_volume(sfx_voice[index], temp_volume);
8497 619271 }
8498
8499 721282 return sfx_voice[index] != -1;
8500 963608 }
8501
8502 int32_t sfx_get_default_freq(int32_t index)
8503 {
8504 if (sfxdat)
8505 {
8506 if (index < Z35)
8507 {
8508 return ((SAMPLE*)sfxdata[index].dat)->freq;
8509 }
8510 else
8511 {
8512 return ((SAMPLE*)sfxdata[Z35].dat)->freq;
8513 }
8514 }
8515 else
8516 {
8517 return customsfxdata[index].freq;
8518 }
8519 }
8520
8521 int32_t sfx_get_length(int32_t index)
8522 {
8523 if (sfxdat)
8524 {
8525 if (index < Z35)
8526 {
8527 return int32_t(((SAMPLE*)sfxdata[index].dat)->len);
8528 }
8529 else
8530 {
8531 return int32_t(((SAMPLE*)sfxdata[Z35].dat)->len);
8532 }
8533 }
8534 else
8535 {
8536 return int32_t(customsfxdata[index].len);
8537 }
8538 }
8539
8540 // plays an sfx sample
8541 963608 void sfx(int32_t index,int32_t pan,bool loop, bool restart, int32_t vol, int32_t freq)
8542 {
8543
2/2
✓ Branch 0 taken 721282 times.
✓ Branch 1 taken 242326 times.
963608 if(!sfx_init(index))
8544 242326 return;
8545
1/2
✓ Branch 0 taken 721282 times.
✗ Branch 1 not taken.
721282 if (!is_headless())
8546 {
8547 voice_set_playmode(sfx_voice[index], loop ? PLAYMODE_LOOP : PLAYMODE_PLAY);
8548 voice_set_pan(sfx_voice[index], pan);
8549
8550 // Only used by ZScript currently
8551 if (freq <= -1)
8552 {
8553 freq = sfx_get_default_freq(index);
8554 }
8555 voice_set_frequency(sfx_voice[index], freq);
8556
8557 // Only used by ZScript currently
8558 int32_t temp_volume = (sfx_volume * vol) / 10000 / 100;
8559 if (!get_qr(qr_OLD_SCRIPT_VOLUME))
8560 temp_volume = (temp_volume * FFCore.usr_sfx_volume) / 10000 / 100;
8561 voice_set_volume(sfx_voice[index], temp_volume);
8562
8563 int32_t pos = voice_get_position(sfx_voice[index]);
8564
8565 if (restart) voice_set_position(sfx_voice[index], 0);
8566
8567 if (pos <= 0)
8568 voice_start(sfx_voice[index]);
8569 }
8570
8571
3/4
✓ Branch 0 taken 398006 times.
✓ Branch 1 taken 323276 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 398006 times.
721282 if (restart && replay_is_debug())
8572
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398006 times.
398006 replay_step_comment(fmt::format("sfx {}", sfx_string[index]));
8573 963608 }
8574
8575 // true if sfx is allocated
8576 67537 bool sfx_allocated(int32_t index)
8577 {
8578
3/4
✓ Branch 0 taken 9408 times.
✓ Branch 1 taken 58129 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9408 times.
67537 return (index>0 && index<WAV_COUNT && sfx_voice[index]!=-1);
8579 }
8580
8581 // start it (in loop mode) if it's not already playing,
8582 // otherwise adjust it to play in loop mode -DD
8583 178463 void cont_sfx(int32_t index)
8584 {
8585
1/2
✓ Branch 0 taken 178463 times.
✗ Branch 1 not taken.
178463 if (is_headless())
8586 178463 return;
8587
8588 if(!sfx_init(index))
8589 {
8590 return;
8591 }
8592
8593 if(voice_get_position(sfx_voice[index])<=0)
8594 {
8595 voice_set_position(sfx_voice[index],0);
8596 voice_set_playmode(sfx_voice[index],PLAYMODE_LOOP);
8597 voice_start(sfx_voice[index]);
8598 }
8599 else
8600 {
8601 adjust_sfx(index, 128, true);
8602 }
8603 178463 }
8604
8605 // adjust parameters while playing
8606 4075 void adjust_sfx(int32_t index,int32_t pan,bool loop)
8607 {
8608
4/6
✓ Branch 0 taken 2315 times.
✓ Branch 1 taken 1760 times.
✓ Branch 2 taken 2315 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2315 times.
4075 if(index<=0 || index>=WAV_COUNT || sfx_voice[index]==-1)
8609 4075 return;
8610
8611 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
8612 voice_set_pan(sfx_voice[index],pan);
8613 4075 }
8614
8615 // pauses a voice
8616 1725 void pause_sfx(int32_t index)
8617 {
8618
3/6
✓ Branch 0 taken 1725 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1725 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1725 times.
1725 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
8619 voice_stop(sfx_voice[index]);
8620 1725 }
8621
8622 // resumes a voice
8623 747 void resume_sfx(int32_t index)
8624 {
8625
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 747 times.
747 if (is_headless())
8626 747 return;
8627
8628 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
8629 voice_start(sfx_voice[index]);
8630 747 }
8631
8632 // pauses all active voices
8633 451 void pause_all_sfx()
8634 {
8635
2/2
✓ Branch 0 taken 115456 times.
✓ Branch 1 taken 451 times.
115907 for(int32_t i=0; i<WAV_COUNT; i++)
8636
2/2
✓ Branch 0 taken 115455 times.
✓ Branch 1 taken 1 times.
115457 if(sfx_voice[i]!=-1)
8637 1 voice_stop(sfx_voice[i]);
8638 451 }
8639
8640 // resumes all paused voices
8641 438 void resume_all_sfx()
8642 {
8643
2/2
✓ Branch 0 taken 112128 times.
✓ Branch 1 taken 438 times.
112566 for(int32_t i=0; i<WAV_COUNT; i++)
8644
1/2
✓ Branch 0 taken 112128 times.
✗ Branch 1 not taken.
112128 if(sfx_voice[i]!=-1)
8645 voice_start(sfx_voice[i]);
8646 438 }
8647
8648 // stops an sfx and deallocates the voice
8649 7318077 void stop_sfx(int32_t index)
8650 {
8651
3/4
✓ Branch 0 taken 6167423 times.
✓ Branch 1 taken 1150654 times.
✓ Branch 2 taken 6167423 times.
✗ Branch 3 not taken.
7318077 if(index<=0 || index>=WAV_COUNT)
8652 1150654 return;
8653
8654
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 6167412 times.
6167423 if(sfx_voice[index]!=-1)
8655 {
8656 11 deallocate_voice(sfx_voice[index]);
8657 11 sfx_voice[index]=-1;
8658 11 }
8659 7318077 }
8660
8661 // Stops SFX played by Hero's item of the given family
8662 128638 void stop_item_sfx(int32_t family)
8663 {
8664 128638 int32_t id=current_item_id(family);
8665
8666
2/2
✓ Branch 0 taken 128083 times.
✓ Branch 1 taken 555 times.
128638 if(id<0)
8667 128083 return;
8668
8669 555 stop_sfx(itemsbuf[id].usesound);
8670 128638 }
8671
8672 3220 void kill_sfx()
8673 {
8674
2/2
✓ Branch 0 taken 824320 times.
✓ Branch 1 taken 3220 times.
827540 for(int32_t i=0; i<WAV_COUNT; i++)
8675
2/2
✓ Branch 0 taken 824314 times.
✓ Branch 1 taken 6 times.
824326 if(sfx_voice[i]!=-1)
8676 {
8677 6 deallocate_voice(sfx_voice[i]);
8678 6 sfx_voice[i]=-1;
8679 6 }
8680 3220 }
8681
8682 659813 int32_t pan(int32_t x)
8683 {
8684
1/4
✓ Branch 0 taken 659813 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
659813 switch(pan_style)
8685 {
8686 case 0:
8687 return 128;
8688
8689 case 1:
8690 659813 return vbound((x>>1)+68,0,255);
8691
8692 case 2:
8693 return vbound(((x*3)>>2)+36,0,255);
8694 }
8695
8696 return vbound(x,0,255);
8697 659813 }
8698
8699 /*******************************/
8700 /******* Input Handlers ********/
8701 /*******************************/
8702
8703 25088805 bool joybtn(int32_t b)
8704 {
8705
1/2
✓ Branch 0 taken 25088805 times.
✗ Branch 1 not taken.
25088805 if(b == 0)
8706 return false;
8707
1/2
✓ Branch 0 taken 25088805 times.
✗ Branch 1 not taken.
25088805 if (b-1 >= joy[joystick_index].num_buttons)
8708 25088805 return false;
8709
8710 return joy[joystick_index].button[b-1].b !=0;
8711 25088805 }
8712
8713 const char* joybtn_name(int32_t b)
8714 {
8715 if (b <= 0 || b > joy[joystick_index].num_buttons)
8716 return "";
8717
8718 return joy[joystick_index].button[b-1].name;
8719 }
8720
8721 int32_t next_press_key();
8722
8723 int32_t next_press_btn()
8724 {
8725 clear_keybuf();
8726 /*bool b[joy[joystick_index].num_buttons+1];
8727
8728 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
8729 b[i]=joybtn(i);*/
8730
8731 //first, we need to wait until they're pressing no buttons
8732 for(;;)
8733 {
8734 if(keypressed())
8735 {
8736 switch(readkey()>>8)
8737 {
8738 case KEY_ESC:
8739 return -1;
8740
8741 case KEY_SPACE:
8742 return 0;
8743 }
8744 }
8745
8746 poll_joystick();
8747 bool done = true;
8748
8749 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
8750 {
8751 if(joybtn(i)) done = false;
8752 }
8753
8754 if(done) break;
8755 rest(1);
8756 }
8757
8758 //now, we need to wait for them to press any button
8759 for(;;)
8760 {
8761 if(keypressed())
8762 {
8763 switch(readkey()>>8)
8764 {
8765 case KEY_ESC:
8766 return -1;
8767
8768 case KEY_SPACE:
8769 return 0;
8770 }
8771 }
8772
8773 poll_joystick();
8774
8775 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
8776 {
8777 if(joybtn(i)) return i;
8778 }
8779 rest(1);
8780 }
8781 }
8782
8783 1198535 static bool rButton(bool &btn, bool &flag, bool rawbtn)
8784 {
8785
2/2
✓ Branch 0 taken 1194055 times.
✓ Branch 1 taken 4480 times.
1198535 bool ret = btn && !flag;
8786 1198535 flag = rawbtn;
8787
8788 1198535 return ret;
8789 }
8790 190895652 static bool rButton(bool &btn, bool &flag)
8791 {
8792
2/2
✓ Branch 0 taken 184052419 times.
✓ Branch 1 taken 6843233 times.
190895652 bool ret = btn && !flag;
8793 190895652 flag = btn;
8794
8795 190895652 return ret;
8796 }
8797 1846969 static bool rButtonPeek(bool btn, bool flag)
8798 {
8799
2/2
✓ Branch 0 taken 1644296 times.
✓ Branch 1 taken 202673 times.
1846969 if(!btn)
8800 {
8801 1644296 return false;
8802 }
8803
2/2
✓ Branch 0 taken 17699 times.
✓ Branch 1 taken 184974 times.
202673 else if(!flag)
8804 {
8805 17699 return true;
8806 }
8807
8808 184974 return false;
8809 1846969 }
8810
8811 // Updated only by keyboard/gamepad.
8812 // If in replay mode, this is set directly by the replay system.
8813 // This should never be read from directly - use control_state instead.
8814 bool raw_control_state[ZC_CONTROL_STATES];
8815
8816 // Every call to load_control_state (pretty much every frame) resets this to be equal to raw_control_state.
8817 // This state can drift from raw_control_state if button states are "eaten" or overriden by a script. But that only
8818 // lasts until the next call to load_control_state.
8819 bool control_state[ZC_CONTROL_STATES];
8820 bool disable_control[ZC_CONTROL_STATES];
8821 bool drunk_toggle_state[11];
8822 bool disabledKeys[127];
8823 bool KeyInput[127];
8824 bool KeyPress[127];
8825
8826 bool key_current_frame[127];
8827 bool key_previous_frame[127];
8828
8829 static bool key_system[127];
8830 static bool key_system_previous[127];
8831 static bool key_system_press[127];
8832
8833 bool button_press[ZC_CONTROL_STATES];
8834 bool button_hold[ZC_CONTROL_STATES];
8835
8836 #define STICK_1_X joy[joystick_index].stick[js_stick_1_x_stick].axis[js_stick_1_x_axis]
8837 #define STICK_1_Y joy[joystick_index].stick[js_stick_1_y_stick].axis[js_stick_1_y_axis]
8838 #define STICK_2_X joy[joystick_index].stick[js_stick_2_x_stick].axis[js_stick_2_x_axis]
8839 #define STICK_2_Y joy[joystick_index].stick[js_stick_2_y_stick].axis[js_stick_2_y_axis]
8840 #define STICK_PRECISION 56 //define your own sensitivity
8841
8842 7799051 void load_control_state()
8843 {
8844 7799051 load_control_called_this_frame = true;
8845
8846
2/2
✓ Branch 0 taken 4831538 times.
✓ Branch 1 taken 2967513 times.
7799051 if (replay_version_check(8, 11))
8847 {
8848
2/2
✓ Branch 0 taken 53415234 times.
✓ Branch 1 taken 2967513 times.
56382747 for (int i = 0; i < ZC_CONTROL_STATES; i++)
8849 53415234 down_control_states[i] = raw_control_state[i];
8850 2967513 }
8851
8852
1/2
✓ Branch 0 taken 7799051 times.
✗ Branch 1 not taken.
7799051 if (!replay_is_replaying())
8853 {
8854 raw_control_state[0]=zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset < -STICK_PRECISION : joybtn(DUbtn));
8855 raw_control_state[1]=zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn));
8856 raw_control_state[2]=zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn));
8857 raw_control_state[3]=zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn));
8858 raw_control_state[4]=zc_getrawkey(Akey, true)||joybtn(Abtn);
8859 raw_control_state[5]=zc_getrawkey(Bkey, true)||joybtn(Bbtn);
8860 raw_control_state[6]=zc_getrawkey(Skey, true)||joybtn(Sbtn);
8861 raw_control_state[7]=zc_getrawkey(Lkey, true)||joybtn(Lbtn);
8862 raw_control_state[8]=zc_getrawkey(Rkey, true)||joybtn(Rbtn);
8863 raw_control_state[9]=zc_getrawkey(Pkey, true)||joybtn(Pbtn);
8864 raw_control_state[10]=zc_getrawkey(Exkey1, true)||joybtn(Exbtn1);
8865 raw_control_state[11]=zc_getrawkey(Exkey2, true)||joybtn(Exbtn2);
8866 raw_control_state[12]=zc_getrawkey(Exkey3, true)||joybtn(Exbtn3);
8867 raw_control_state[13]=zc_getrawkey(Exkey4, true)||joybtn(Exbtn4);
8868
8869 if(num_joysticks != 0)
8870 {
8871 raw_control_state[14] = STICK_2_Y.pos - js_stick_2_y_offset < -STICK_PRECISION;
8872 raw_control_state[15] = STICK_2_Y.pos - js_stick_2_y_offset > STICK_PRECISION;
8873 raw_control_state[16] = STICK_2_X.pos - js_stick_2_x_offset < -STICK_PRECISION;
8874 raw_control_state[17] = STICK_2_X.pos - js_stick_2_x_offset > STICK_PRECISION;
8875 // zprint2("Detected %d joysticks... %d%d%d%d\n", num_joysticks, raw_control_state[14]?1:0, raw_control_state[15]?1:0, raw_control_state[16]?1:0, raw_control_state[17]?1:0);
8876 }
8877 else
8878 {
8879 raw_control_state[14] = false;
8880 raw_control_state[15] = false;
8881 raw_control_state[16] = false;
8882 raw_control_state[17] = false;
8883 // zprint2("Detected 0 joysticks... clearing inputaxis values.\n");
8884 }
8885 }
8886
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 7799048 times.
7799051 if (replay_is_active())
8887 {
8888
2/2
✓ Branch 0 taken 1015215 times.
✓ Branch 1 taken 6783833 times.
7799048 if (replay_get_version() < 3)
8889 1015215 replay_poll();
8890
3/4
✓ Branch 0 taken 6783833 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5022458 times.
✓ Branch 3 taken 1761375 times.
6783833 else if (replay_is_replaying() && replay_get_version() < 6)
8891 1761375 replay_peek_input();
8892
3/4
✓ Branch 0 taken 5022458 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2054945 times.
✓ Branch 3 taken 2967513 times.
5022458 else if (replay_is_replaying() && replay_version_check(8, 11))
8893 2967513 replay_peek_input();
8894
2/2
✓ Branch 0 taken 6694758 times.
✓ Branch 1 taken 1104290 times.
7799048 if (replay_get_version() == 8)
8895 1104290 update_keys();
8896 7799048 }
8897
8898 // Some test replay files were made before a serious input bug was fixed, so instead
8899 // of re-doing them or tossing them out, just check for that zplay version.
8900
3/4
✓ Branch 0 taken 7799045 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 121900 times.
✓ Branch 3 taken 7677145 times.
7799051 bool botched_input = replay_is_active() && replay_get_version() != 1 && replay_get_version() < 8;
8901
2/2
✓ Branch 0 taken 140382810 times.
✓ Branch 1 taken 7799045 times.
148181855 for (int i = 0; i < ZC_CONTROL_STATES; i++)
8902 {
8903 140382810 control_state[i] = raw_control_state[i];
8904
4/4
✓ Branch 0 taken 49487310 times.
✓ Branch 1 taken 90895500 times.
✓ Branch 2 taken 2410168 times.
✓ Branch 3 taken 47077142 times.
140382810 if (botched_input && !control_state[i])
8905 47077142 down_control_states[i] = false;
8906 140382810 }
8907 7799045 bool did_bad_cutscene_btn = false;
8908
2/2
✓ Branch 0 taken 7799045 times.
✓ Branch 1 taken 140382810 times.
148181855 for(int q = 0; q < 18; ++q)
8909
3/4
✓ Branch 0 taken 6462860 times.
✓ Branch 1 taken 133919950 times.
✓ Branch 2 taken 6462860 times.
✗ Branch 3 not taken.
140382810 if(control_state[q] && !active_cutscene.can_button(q))
8910 {
8911 control_state[q] = false;
8912 did_bad_cutscene_btn = true;
8913 }
8914
1/2
✓ Branch 0 taken 7799045 times.
✗ Branch 1 not taken.
7799045 if(did_bad_cutscene_btn)
8915 active_cutscene.error();
8916
8917 7799045 button_press[0]=rButton(control_state[0],button_hold[0]);
8918 7799045 button_press[1]=rButton(control_state[1],button_hold[1]);
8919 7799045 button_press[2]=rButton(control_state[2],button_hold[2]);
8920 7799045 button_press[3]=rButton(control_state[3],button_hold[3]);
8921 7799045 button_press[4]=rButton(control_state[4],button_hold[4]);
8922 7799045 button_press[5]=rButton(control_state[5],button_hold[5]);
8923 7799045 button_press[6]=rButton(control_state[6],button_hold[6]);
8924 7799045 button_press[7]=rButton(control_state[7],button_hold[7]);
8925 7799045 button_press[8]=rButton(control_state[8],button_hold[8]);
8926 7799045 button_press[9]=rButton(control_state[9],button_hold[9]);
8927 7799045 button_press[10]=rButton(control_state[10],button_hold[10]);
8928 7799045 button_press[11]=rButton(control_state[11],button_hold[11]);
8929 7799045 button_press[12]=rButton(control_state[12],button_hold[12]);
8930 7799045 button_press[13]=rButton(control_state[13],button_hold[13]);
8931 7799045 button_press[14]=rButton(control_state[14],button_hold[14]);
8932 7799045 button_press[15]=rButton(control_state[15],button_hold[15]);
8933 7799045 button_press[16]=rButton(control_state[16],button_hold[16]);
8934 7799045 button_press[17]=rButton(control_state[17],button_hold[17]);
8935 7799045 }
8936
8937 // Returns true if any game key is pressed. This is needed because keypressed()
8938 // doesn't detect modifier keys and control_state[] can be modified by scripts.
8939 40242214 bool zc_key_pressed()
8940 //may also need to use zc_getrawkey
8941 {
8942
7/10
✓ Branch 0 taken 32591229 times.
✓ Branch 1 taken 7650985 times.
✓ Branch 2 taken 7650985 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7650985 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6394916 times.
✓ Branch 7 taken 6394916 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 2461268 times.
42703482 if((zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset< -STICK_PRECISION : joybtn(DUbtn))) ||
8943
4/6
✓ Branch 0 taken 6394916 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6394916 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4843285 times.
✓ Branch 5 taken 4843285 times.
6394916 (zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn))) ||
8944
4/6
✓ Branch 0 taken 4843285 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4843285 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3142666 times.
✓ Branch 5 taken 3142666 times.
4843285 (zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn))) ||
8945
4/6
✓ Branch 0 taken 3142666 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3142666 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2731732 times.
✓ Branch 5 taken 2731732 times.
3142666 (zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn))) ||
8946
1/2
✓ Branch 0 taken 2731732 times.
✗ Branch 1 not taken.
2731732 (zc_getrawkey(Akey, true)||joybtn(Abtn)) ||
8947
3/4
✓ Branch 0 taken 2612325 times.
✓ Branch 1 taken 119407 times.
✓ Branch 2 taken 2612325 times.
✗ Branch 3 not taken.
2731732 (zc_getrawkey(Bkey, true)||joybtn(Bbtn)) ||
8948
3/4
✓ Branch 0 taken 2493431 times.
✓ Branch 1 taken 118894 times.
✓ Branch 2 taken 2493431 times.
✗ Branch 3 not taken.
2612325 (zc_getrawkey(Skey, true)||joybtn(Sbtn)) ||
8949
3/4
✓ Branch 0 taken 2478286 times.
✓ Branch 1 taken 15145 times.
✓ Branch 2 taken 2478286 times.
✗ Branch 3 not taken.
2493431 (zc_getrawkey(Lkey, true)||joybtn(Lbtn)) ||
8950
3/4
✓ Branch 0 taken 2464787 times.
✓ Branch 1 taken 13499 times.
✓ Branch 2 taken 2464787 times.
✗ Branch 3 not taken.
2478286 (zc_getrawkey(Rkey, true)||joybtn(Rbtn)) ||
8951
3/4
✓ Branch 0 taken 2462293 times.
✓ Branch 1 taken 2494 times.
✓ Branch 2 taken 2462293 times.
✗ Branch 3 not taken.
2464787 (zc_getrawkey(Pkey, true)||joybtn(Pbtn)) ||
8952
3/4
✓ Branch 0 taken 2462103 times.
✓ Branch 1 taken 190 times.
✓ Branch 2 taken 2462103 times.
✗ Branch 3 not taken.
2462293 (zc_getrawkey(Exkey1, true)||joybtn(Exbtn1)) ||
8953
3/4
✓ Branch 0 taken 2461293 times.
✓ Branch 1 taken 810 times.
✓ Branch 2 taken 2461293 times.
✗ Branch 3 not taken.
2462103 (zc_getrawkey(Exkey2, true)||joybtn(Exbtn2)) ||
8954
3/4
✓ Branch 0 taken 2461287 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 2461287 times.
✗ Branch 3 not taken.
2461293 (zc_getrawkey(Exkey3, true)||joybtn(Exbtn3)) ||
8955
2/2
✓ Branch 0 taken 2461268 times.
✓ Branch 1 taken 19 times.
2461287 (zc_getrawkey(Exkey4, true)||joybtn(Exbtn4))) // Skipping joystick axes
8956 72006144 return true;
8957
8958 2461268 return false;
8959 9284954 }
8960
8961 149218894 bool getInput(int32_t btn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
8962 {
8963 149218894 bool ret = false, drunkstate = false, rawret = false;;
8964 149218894 bool* flag = &down_control_states[btn];
8965
2/7
✓ Branch 0 taken 139924604 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 9294290 times.
149218894 switch(btn)
8966 {
8967 case btnF12:
8968 ret = zc_getkey(KEY_F12, ignoreDisable);
8969 rawret = zc_getrawkey(KEY_F12, ignoreDisable);
8970 eatEntirely = false;
8971 break;
8972 case btnF11:
8973 ret = zc_getkey(KEY_F11, ignoreDisable);
8974 rawret = zc_getrawkey(KEY_F11, ignoreDisable);
8975 eatEntirely = false;
8976 break;
8977 case btnF5:
8978 ret = zc_getkey(KEY_F5, ignoreDisable);
8979 rawret = zc_getrawkey(KEY_F5, ignoreDisable);
8980 eatEntirely = false;
8981 break;
8982 case btnQ:
8983 ret = zc_getkey(KEY_Q, ignoreDisable);
8984 rawret = zc_getrawkey(KEY_Q, ignoreDisable);
8985 eatEntirely = false;
8986 break;
8987 case btnI:
8988 ret = zc_getkey(KEY_I, ignoreDisable);
8989 rawret = zc_getrawkey(KEY_I, ignoreDisable);
8990 eatEntirely = false;
8991 break;
8992 case btnM:
8993
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9294290 times.
9294290 if(FFCore.kb_typing_mode) return false;
8994 9294290 rawret = ret = zc_getrawkey(KEY_ESC, ignoreDisable);
8995 9294290 eatEntirely = false;
8996 9294290 break;
8997 default: //control_state[] index
8998
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 139924604 times.
139924604 if(FFCore.kb_typing_mode) return false;
8999
5/6
✓ Branch 0 taken 139125147 times.
✓ Branch 1 taken 799457 times.
✓ Branch 2 taken 2190363 times.
✓ Branch 3 taken 136934784 times.
✓ Branch 4 taken 2190363 times.
✗ Branch 5 not taken.
139924604 if(!ignoreDisable && get_qr(qr_FIXDRUNKINPUTS) && disable_control[btn]) drunk = false;
9000
2/2
✓ Branch 0 taken 7643662 times.
✓ Branch 1 taken 132280942 times.
139924604 else if(btn<11) drunkstate = drunk_toggle_state[btn];
9001
4/4
✓ Branch 0 taken 125762930 times.
✓ Branch 1 taken 14161674 times.
✓ Branch 2 taken 2995 times.
✓ Branch 3 taken 14158679 times.
154086278 ret = control_state[btn] && (ignoreDisable || !disable_control[btn]);
9002 139924604 rawret = raw_control_state[btn];
9003 139924604 }
9004
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 149218894 times.
149218894 assert(flag);
9005
2/2
✓ Branch 0 taken 95660548 times.
✓ Branch 1 taken 53558346 times.
149218894 if(press)
9006 {
9007
2/2
✓ Branch 0 taken 1846969 times.
✓ Branch 1 taken 51711377 times.
53558346 if(peek)
9008 1846969 ret = rButtonPeek(ret, *flag);
9009
2/2
✓ Branch 0 taken 50512842 times.
✓ Branch 1 taken 1198535 times.
51711377 else if(get_qr(qr_BROKEN_INPUT_DOWN_STATE)) ret = rButton(ret, *flag);
9010 1198535 else ret = rButton(ret, *flag, rawret);
9011 53558346 }
9012
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 149218894 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
149218894 if(eatEntirely && ret) control_state[btn] = false;
9013
3/4
✓ Branch 0 taken 112177277 times.
✓ Branch 1 taken 37041617 times.
✓ Branch 2 taken 112177277 times.
✗ Branch 3 not taken.
149218894 if(drunk && drunkstate) ret = !ret;
9014 149218894 return ret;
9015 149218894 }
9016
9017 7333007 byte getIntBtnInput(byte intbtn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
9018 {
9019 7333007 byte ret = 0;
9020
2/2
✓ Branch 0 taken 5483939 times.
✓ Branch 1 taken 1849068 times.
7333007 if(intbtn & INT_BTN_A) ret |= getInput(btnA, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_A : 0;
9021
2/2
✓ Branch 0 taken 7332445 times.
✓ Branch 1 taken 562 times.
7333007 if(intbtn & INT_BTN_B) ret |= getInput(btnB, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_B : 0;
9022
2/2
✓ Branch 0 taken 7332570 times.
✓ Branch 1 taken 437 times.
7333007 if(intbtn & INT_BTN_L) ret |= getInput(btnL, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_L : 0;
9023
2/2
✓ Branch 0 taken 7332570 times.
✓ Branch 1 taken 437 times.
7333007 if(intbtn & INT_BTN_R) ret |= getInput(btnR, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_R : 0;
9024
2/2
✓ Branch 0 taken 7332570 times.
✓ Branch 1 taken 437 times.
7333007 if(intbtn & INT_BTN_EX1) ret |= getInput(btnEx1, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX1 : 0;
9025
2/2
✓ Branch 0 taken 7332570 times.
✓ Branch 1 taken 437 times.
7333007 if(intbtn & INT_BTN_EX2) ret |= getInput(btnEx2, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX2 : 0;
9026
2/2
✓ Branch 0 taken 7332570 times.
✓ Branch 1 taken 437 times.
7333007 if(intbtn & INT_BTN_EX3) ret |= getInput(btnEx3, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX3 : 0;
9027
2/2
✓ Branch 0 taken 7332570 times.
✓ Branch 1 taken 437 times.
7333007 if(intbtn & INT_BTN_EX4) ret |= getInput(btnEx4, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX4 : 0;
9028 7333007 return ret; //No early return, to make sure all button presses are eaten that should be! -Em
9029 }
9030
9031 1114 byte checkIntBtnVal(byte intbtn, byte vals)
9032 {
9033 1114 return intbtn&vals;
9034 }
9035
9036 1767241 bool Up()
9037 {
9038 1767241 return getInput(btnUp);
9039 }
9040 146943 bool Down()
9041 {
9042 146943 return getInput(btnDown);
9043 }
9044 257358 bool Left()
9045 {
9046 257358 return getInput(btnLeft);
9047 }
9048 286551 bool Right()
9049 {
9050 286551 return getInput(btnRight);
9051 }
9052 164908 bool cAbtn()
9053 {
9054 164908 return getInput(btnA);
9055 }
9056 1411891 bool cBbtn()
9057 {
9058 1411891 return getInput(btnB);
9059 }
9060 bool cSbtn()
9061 {
9062 return getInput(btnS);
9063 }
9064 68744 bool cLbtn()
9065 {
9066 68744 return getInput(btnL);
9067 }
9068 68744 bool cRbtn()
9069 {
9070 68744 return getInput(btnR);
9071 }
9072 bool cPbtn()
9073 {
9074 return getInput(btnP);
9075 }
9076 bool cEx1btn()
9077 {
9078 return getInput(btnEx1);
9079 }
9080 bool cEx2btn()
9081 {
9082 return getInput(btnEx2);
9083 }
9084 bool cEx3btn()
9085 {
9086 return getInput(btnEx3);
9087 }
9088 bool cEx4btn()
9089 {
9090 return getInput(btnEx4);
9091 }
9092 bool AxisUp()
9093 {
9094 return getInput(btnAxisUp);
9095 }
9096 bool AxisDown()
9097 {
9098 return getInput(btnAxisDown);
9099 }
9100 bool AxisLeft()
9101 {
9102 return getInput(btnAxisLeft);
9103 }
9104 bool AxisRight()
9105 {
9106 return getInput(btnAxisRight);
9107 }
9108
9109 bool cMbtn()
9110 {
9111 return getInput(btnM);
9112 }
9113 bool cF12()
9114 {
9115 return getInput(btnF12);
9116 }
9117 bool cF11()
9118 {
9119 return getInput(btnF11);
9120 }
9121 bool cF5()
9122 {
9123 return getInput(btnF5);
9124 }
9125 bool cQ()
9126 {
9127 return getInput(btnQ);
9128 }
9129 bool cI()
9130 {
9131 return getInput(btnI);
9132 }
9133
9134 130270 bool rUp()
9135 {
9136 130270 return getInput(btnUp, true);
9137 }
9138 130174 bool rDown()
9139 {
9140 130174 return getInput(btnDown, true);
9141 }
9142 130122 bool rLeft()
9143 {
9144 130122 return getInput(btnLeft, true);
9145 }
9146 129657 bool rRight()
9147 {
9148 129657 return getInput(btnRight, true);
9149 }
9150 3145 bool rAbtn()
9151 {
9152 3145 return getInput(btnA, true);
9153 }
9154 131548 bool rBbtn()
9155 {
9156 131548 return getInput(btnB, true);
9157 }
9158 7395153 bool rSbtn()
9159 {
9160 7395153 return getInput(btnS, true);
9161 }
9162 9284954 bool rMbtn()
9163 {
9164 9284954 return getInput(btnM, true);
9165 }
9166 129441 bool rLbtn()
9167 {
9168 129441 return getInput(btnL, true);
9169 }
9170 129436 bool rRbtn()
9171 {
9172 129436 return getInput(btnR, true);
9173 }
9174 7331617 bool rPbtn()
9175 {
9176 7331617 return getInput(btnP, true);
9177 }
9178 bool rEx1btn()
9179 {
9180 return getInput(btnEx1, true);
9181 }
9182 bool rEx2btn()
9183 {
9184 return getInput(btnEx2, true);
9185 }
9186 140087 bool rEx3btn()
9187 {
9188 140087 return getInput(btnEx3, true);
9189 }
9190 140087 bool rEx4btn()
9191 {
9192 140087 return getInput(btnEx4, true);
9193 }
9194 bool rAxisUp()
9195 {
9196 return getInput(btnAxisUp, true);
9197 }
9198 bool rAxisDown()
9199 {
9200 return getInput(btnAxisDown, true);
9201 }
9202 bool rAxisLeft()
9203 {
9204 return getInput(btnAxisLeft, true);
9205 }
9206 bool rAxisRight()
9207 {
9208 return getInput(btnAxisRight, true);
9209 }
9210
9211 bool rF11()
9212 {
9213 return getInput(btnF11, true);
9214 }
9215 bool rQ()
9216 {
9217 return getInput(btnQ, true);
9218 }
9219 bool rI()
9220 {
9221 return getInput(btnI, true);
9222 }
9223
9224 18221767 bool DrunkUp()
9225 {
9226 18221767 return getInput(btnUp, false, true);
9227 }
9228 16885102 bool DrunkDown()
9229 {
9230 16885102 return getInput(btnDown, false, true);
9231 }
9232 10286365 bool DrunkLeft()
9233 {
9234 10286365 return getInput(btnLeft, false, true);
9235 }
9236 8832532 bool DrunkRight()
9237 {
9238 8832532 return getInput(btnRight, false, true);
9239 }
9240 8034063 bool DrunkcAbtn()
9241 {
9242 8034063 return getInput(btnA, false, true);
9243 }
9244 7848592 bool DrunkcBbtn()
9245 {
9246 7848592 return getInput(btnB, false, true);
9247 }
9248 7262487 bool DrunkcEx1btn()
9249 {
9250 7262487 return getInput(btnEx1, false, true);
9251 }
9252 7262507 bool DrunkcEx2btn()
9253 {
9254 7262507 return getInput(btnEx2, false, true);
9255 }
9256 bool DrunkcSbtn()
9257 {
9258 return getInput(btnS, false, true);
9259 }
9260 bool DrunkcMbtn()
9261 {
9262 return getInput(btnM, false, true);
9263 }
9264 bool DrunkcLbtn()
9265 {
9266 return getInput(btnL, false, true);
9267 }
9268 bool DrunkcRbtn()
9269 {
9270 return getInput(btnR, false, true);
9271 }
9272 bool DrunkcPbtn()
9273 {
9274 return getInput(btnP, false, true);
9275 }
9276
9277 bool DrunkrUp()
9278 {
9279 return getInput(btnUp, true, true);
9280 }
9281 bool DrunkrDown()
9282 {
9283 return getInput(btnDown, true, true);
9284 }
9285 bool DrunkrLeft()
9286 {
9287 return getInput(btnLeft, true, true);
9288 }
9289 bool DrunkrRight()
9290 {
9291 return getInput(btnRight, true, true);
9292 }
9293 6080192 bool DrunkrAbtn()
9294 {
9295 6080192 return getInput(btnA, true, true);
9296 }
9297 6097024 bool DrunkrBbtn()
9298 {
9299 6097024 return getInput(btnB, true, true);
9300 }
9301 71669 bool DrunkrEx1btn()
9302 {
9303 71669 return getInput(btnEx1, true, true);
9304 }
9305 71662 bool DrunkrEx2btn()
9306 {
9307 71662 return getInput(btnEx2, true, true);
9308 }
9309 bool DrunkrEx3btn()
9310 {
9311 return getInput(btnEx3, true, true);
9312 }
9313 bool DrunkrEx4btn()
9314 {
9315 return getInput(btnEx4, true, true);
9316 }
9317 bool DrunkrSbtn()
9318 {
9319 return getInput(btnS, true, true);
9320 }
9321 bool DrunkrMbtn()
9322 {
9323 return getInput(btnM, true, true);
9324 }
9325 6687269 bool DrunkrLbtn()
9326 {
9327 6687269 return getInput(btnL, true, true);
9328 }
9329 6683794 bool DrunkrRbtn()
9330 {
9331 6683794 return getInput(btnR, true, true);
9332 }
9333 bool DrunkrPbtn()
9334 {
9335 return getInput(btnP, true, true);
9336 }
9337
9338 9336 void eat_buttons()
9339 {
9340 9336 getInput(btnA, true, false, true);
9341 9336 getInput(btnB, true, false, true);
9342 9336 getInput(btnS, true, false, true);
9343 9336 getInput(btnM, true, false, true);
9344 9336 getInput(btnL, true, false, true);
9345 9336 getInput(btnR, true, false, true);
9346 9336 getInput(btnP, true, false, true);
9347 9336 getInput(btnEx1, true, false, true);
9348 9336 getInput(btnEx2, true, false, true);
9349 9336 getInput(btnEx3, true, false, true);
9350 9336 getInput(btnEx4, true, false, true);
9351 9336 }
9352
9353 // Is true for the _first frame_ of a key press.
9354 // But! it is possible that a script manually sets the value of KeyPress,
9355 // in which case it will be restored to the "true" value based on `key_current_frame`
9356 // and `key_previous_frame` on the next frame.
9357 13 bool zc_readkey(int32_t k, bool ignoreDisable)
9358 {
9359
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(ignoreDisable) return KeyPress[k];
9360
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 switch(k)
9361 {
9362 case KEY_F7:
9363 case KEY_F8:
9364 case KEY_F9:
9365 return KeyPress[k];
9366
9367 default:
9368
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 return KeyPress[k] && !disabledKeys[k];
9369 }
9370 13 }
9371
9372 // Is true for _every frame_ a key is held down.
9373 // But! it is possible that a script manually sets the value of KeyInput,
9374 // in which case it will be restored to the "true" value based on `key_current_frame`
9375 // on the next frame.
9376 bool zc_getkey(int32_t k, bool ignoreDisable)
9377 {
9378 if(ignoreDisable) return KeyInput[k];
9379 switch(k)
9380 {
9381 case KEY_F7:
9382 case KEY_F8:
9383 case KEY_F9:
9384 return KeyInput[k];
9385
9386 default:
9387 return KeyInput[k] && !disabledKeys[k];
9388 }
9389 }
9390
9391 // Reads (and then clears) the current frame key state directly.
9392 // Scripts can also modify `key_current_frame`.
9393 300 bool zc_readrawkey(int32_t k, bool ignoreDisable)
9394 {
9395
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 298 times.
300 if(zc_getrawkey(k, ignoreDisable))
9396 {
9397 2 _key[k]=key[k]=key_current_frame[k]=0;
9398 2 return true;
9399 }
9400 298 _key[k]=key[k]=key_current_frame[k]=0;
9401 298 return false;
9402 300 }
9403
9404 // Reads the current frame key state directly.
9405 // Scripts can also modify `key_current_frame`.
9406 63238933 bool zc_getrawkey(int32_t k, bool ignoreDisable)
9407 {
9408
2/2
✓ Branch 0 taken 53953953 times.
✓ Branch 1 taken 9284980 times.
63238933 if(ignoreDisable) return key_current_frame[k];
9409
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9284980 times.
9284980 switch(k)
9410 {
9411 case KEY_F7:
9412 case KEY_F8:
9413 case KEY_F9:
9414 return key_current_frame[k];
9415
9416 default:
9417
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9284980 times.
9284980 return key_current_frame[k] && !disabledKeys[k];
9418 }
9419 63238933 }
9420
9421 // Only used for a handful of keys, like tilde and Function keys.
9422 // This state is never read within the game.
9423 // It exists so that all keyboard input still functions during replay,
9424 // without inadvertently doing things like toggling throttling if the player
9425 // presses ~
9426 9284954 bool zc_get_system_key(int32_t k)
9427 {
9428 9284954 return key_system[k];
9429 }
9430
9431 // True for the _first_ frame of a key press.
9432 83564586 bool zc_read_system_key(int32_t k)
9433 {
9434 83564586 return key_system_press[k];
9435 }
9436
9437 1179189158 bool is_system_key(int32_t k)
9438 {
9439
2/2
✓ Branch 0 taken 1095624572 times.
✓ Branch 1 taken 83564586 times.
1179189158 switch (k)
9440 {
9441 case KEY_BACKQUOTE:
9442 case KEY_CLOSEBRACE:
9443 case KEY_END:
9444 case KEY_HOME:
9445 case KEY_OPENBRACE:
9446 case KEY_PGDN:
9447 case KEY_PGUP:
9448 case KEY_TAB:
9449 case KEY_TILDE:
9450 83564586 return true;
9451 }
9452 1095624572 return is_Fkey(k);
9453 1179189158 }
9454
9455 9284954 void update_system_keys()
9456 {
9457
2/2
✓ Branch 0 taken 1179189158 times.
✓ Branch 1 taken 9284954 times.
1188474112 for (int32_t q = 0; q < 127; ++q)
9458 {
9459
2/2
✓ Branch 0 taken 194984034 times.
✓ Branch 1 taken 984205124 times.
1179189158 if (!is_system_key(q))
9460 984205124 continue;
9461
9462 194984034 key_system[q] = key[q];
9463
1/2
✓ Branch 0 taken 194984034 times.
✗ Branch 1 not taken.
194984034 key_system_press[q] = key_system[q] && !key_system_previous[q];
9464 194984034 key_system_previous[q] = key_system[q];
9465 194984034 }
9466 9284954 }
9467
9468 10389244 void update_keys()
9469 {
9470
2/2
✓ Branch 0 taken 1319433988 times.
✓ Branch 1 taken 10389244 times.
1329823232 for (int32_t q = 0; q < 127; ++q)
9471 {
9472 // When replaying, replay.cpp takes care of updating `key_current_frame`.
9473
1/2
✓ Branch 0 taken 1319433988 times.
✗ Branch 1 not taken.
1319433988 if (!replay_is_replaying())
9474 key_current_frame[q] = key[q];
9475
9476
2/2
✓ Branch 0 taken 1309647613 times.
✓ Branch 1 taken 9786375 times.
1319433988 KeyPress[q] = key_current_frame[q] && !key_previous_frame[q];
9477 1319433988 KeyInput[q] = key_current_frame[q];
9478 1319433988 key_previous_frame[q] = key_current_frame[q];
9479 1319433988 }
9480 10389244 }
9481
9482 bool zc_disablekey(int32_t k, bool val)
9483 {
9484 switch(k)
9485 {
9486 case KEY_F7:
9487 case KEY_F8:
9488 case KEY_F9:
9489 return false;
9490
9491 default:
9492 disabledKeys[k] = val;
9493 return true;
9494 }
9495 }
9496
9497 void zc_putpixel(int32_t layer, int32_t x, int32_t y, int32_t cset, int32_t color, int32_t timer)
9498 {
9499 timer=timer;
9500 particles.add(new particle(zfix(x), zfix(y), layer, cset, color));
9501 }
9502